vb to change query criteria

M

msmuzila

What is the vb code to change a queries criteria (stored query). I need
to have the query filter the following so this needs to be on the
criteria line: 33 Or 48
 
J

John Vinson

What is the vb code to change a queries criteria (stored query). I need
to have the query filter the following so this needs to be on the
criteria line: 33 Or 48

Well, why not use a Parameter Query instead of trying to modify a
query with hardwired criteria? If you have a criterion

[Enter first value:] OR [Enter second value:]

you'll get prompted for two values, and not NEED to override them.

Could you post the SQL view of the query you have now? We have no way
of knowing what it is you're changing, so it's hard to tell how to
change it!

John W. Vinson[MVP]
 
M

msmuzila

SELECT Year([SHIP_DATE]) AS [Year], Sum(ORDER_DETAILS.EX_PRICE) AS
Sales
FROM (ORDER_DETAILS INNER JOIN Invoices ON ORDER_DETAILS.ORDER_ID =
Invoices.INV_NO) INNER JOIN Products ON ORDER_DETAILS.PRODUCT =
Products.Product
WHERE (((Products.ID)=GetCombo30(33)) AND ((Invoices.FINALIZED)=True))
GROUP BY Year([SHIP_DATE])
HAVING (((Year([SHIP_DATE]))>Year(Now())-6));

I have specific number group that i want to input from an option group.
So i dont want it to ask everytime.
 
J

John Vinson

SELECT Year([SHIP_DATE]) AS [Year], Sum(ORDER_DETAILS.EX_PRICE) AS
Sales
FROM (ORDER_DETAILS INNER JOIN Invoices ON ORDER_DETAILS.ORDER_ID =
Invoices.INV_NO) INNER JOIN Products ON ORDER_DETAILS.PRODUCT =
Products.Product
WHERE (((Products.ID)=GetCombo30(33)) AND ((Invoices.FINALIZED)=True))
GROUP BY Year([SHIP_DATE])
HAVING (((Year([SHIP_DATE]))>Year(Now())-6));

I have specific number group that i want to input from an option group.
So i dont want it to ask everytime.

What's the name of the Form containing the option group?
What's the name of the option group?
What field is to be constrained by the option group value?
What criterion do you want? Your example listed an OR but an option
group can have only one value.
What's the GetCombo30() function do?

Remember - YOU can see your database. You know what you want. We
cannot and do not.

John W. Vinson[MVP]
 
M

msmuzila

How do i write, in vb, that i want Text42 and Text43 to be the criteria
of a query named query1.
 
J

John Vinson

How do i write, in vb, that i want Text42 and Text43 to be the criteria
of a query named query1.

You'll need to build the SQL of the query in code, I'd say. SQL
queries have no knowledge of, or access to, VBA variables.

I still don't understand what you're trying to accomplish, nor what
field Text42 and Text43 should be applied to.

John W. Vinson[MVP]
 
Top