Fred:
Following is my SQL.
SELECT [Jan 2005 P&L].[Co], [Jan 2005 P&L].[Acct], [Jan 2005 P&L].[Sub],
[Acct] & "-" & [Sub] AS [Account Nbr], [Jan 2005 P&L].[Category], [Jan 2005
P&L].[Desc], [Jan 2005 P&L].[Amount]
FROM [Jan 2005 P&L]
WHERE ((([Jan 2005 P&L].[Co]) Like [Enter Company:]) And (([Jan 2005
P&L].[Acct]) Between 3000 And 3999)) Or (([Enter Company:] Is Null))
ORDER BY [Jan 2005 P&L].[Co], [Jan 2005 P&L].[Acct], [Jan 2005 P&L].[Sub];
Co is a text field, Acct is a number field.
fredg said:
To answer your direct question, yes you can have criteria on 2 (and 3
and 4, etc.) different fields as criteria.
However, as you haven't posted your SQL, it's not possible to tell you
why your query is not working. If you care to post the SQL back,
include the datatypes of whatever fields are used in the criteria.
Why are you using "Like [[Enter Company:] " when you aren't using any
wildcard?
If you are not using a wildcard, then use
WHERE [Jan 2005 P&L].[Co] = [Enter Company:].
If you wish to show only those records where the [Acct] is within the
indicated range for the Company entered in the [prompt] (and allow
just the beginning part of the company name to be entered):
.......
WHERE [Jan 2005 P&L].[Co] Like [Enter Company:] & "*" And [Jan 2005
P&L].[Acct] Between 3000 And 3999
ORDER BY etc ....
If you wish to show as above, OR show ALL the records if nothing is
entered in the prompt:
WHERE ([Jan 2005 P&L].[Co] Like [Enter Company:] & "*" And [Jan 2005
P&L].[Acct] Between 3000 And 3999) Or [Enter Company:] Is Null
Order By etc ...
Part of your problem may be in the actual datatype of the [CO] field.
You write that it is Text, but if you are actually storing [CO] as a
Number in this table (such as a LookUp field or from the bound column
of a Combo box), then you should write:
WHERE ([Jan 2005 P&L].[CO] = [Enter Company ID:] etc..
and enter the actual [CompanyID] number value, not the Company Name as
text.
It's best to use a parameter form with a combo box to assure the
correct CompanyID value is selected. The bound column of the combo box
should be the CompanyID field.
Now you would use, as query criteria:
WHERE ([Jan 2005 P&L].[Co] = forms!FormName!ComboBoxName And [Jan 2005
P&L].[Acct] etc ....) Or forms!FormName!ComboBoxName Is Null
Order By etc.
I hope this has helped.