Without seeling the actual SQL statement.
You can have criteria for every column in your query, but if some criteria is sometimes not entered then you have to use the following
e.g.
Forms!MyForm!myControl OR Forms!MyForm!myControl IS NULL
The query builder will expand this for you, placing the OR in a seperate column and it looks quite horrendous.
WHERE (([FieldName1]=Forms!YourFormName!YourControlName Or Forms!YourFormName!YourControlName Is Null)=True) And (([FieldName2]=Forms!YourFormName!YourControlName Or Forms!YourFormName!YourControlName Is Null)=True)
Thanks, actually the example I have is a data input form for the user to enter a date range (which i did successfully) and a customer name (I did not succeede to do both). this form will feed a report query to filter the report to that specific date range for that customer only.
the criteria I use for the date range (suuccessfuly) in the report query field of "EndDate" is:
Between [Forms]![DateInput]![txtStartingDate] And [Forms]![DateInput]![txtEndingDate]
I then under the customer field I entered:
Forms![DateInput]![txtCompanyName]
but it continue to show the date range successfuly with all customers (customer not filtered).
I am sure my code is missing something,
any suggestion
WHERE (([Field Name for Customer from Table]=Forms!DateInput!txtCompanyName Or Forms!DateInput!txtCompanyName Is Null)=True) And ([EndDate] Between Forms!DateInput!txtStartingDate and Forms!DateInput!txtEndingDate);
thanks, but where should I put that code.
I tried to put it in the report query criteria but gave me message of undefined where. I also tried to put it in the OnOpen event of the report but gave me message of can not find macro where ......
thanks for any tipes
SELECT YourTableName.*
FROM YourTableName
WHERE (Repeat the code I quoted in the previous post after changing that field name to the field for the customer from your table)
how do you do that (where do you write the code in the stand alone query).
and why can't I use the report query since I have half of it working (date range)
sorry for my beginner's question
thanks for your patience. I tried it but something is wrong because the report is dependant on 2 tables "tbl_Orders" and tbl_Customers". whenI am done with your suggestion, Access keeps asking me for too many paremeters values which it is supposed to be got from the DataInput form.
Can you help me modify my existing report query instead of creating a new one. I just want to modify the report query to filter two things:
Date range: I did thanks to memebers of this forum
Comapny Name: I am not able to
thanks a lot