I want to set up a parameter query to run from data input into a form. I'd like users to be able to search on however many fields they want to. So:
Form looks like:
Name:
Organisation:
Address1:
Address2:
Suburb:
Postcode:
And the user can enter data in as many fields as possible to narrow the search.
I've followed the below instructions to set up my form and query:
http://office.microsoft.com/en-au/access/HA011170771033.aspx?pid=CL100570041033
Which results in a query where the criteria refers back to the form, like below (I've added the wildcards so that the user can enter part of the name):
Like "*" & [Forms]![FRM: Data entry form]![Name] & "*"
SQL for whole query looks like (I've spaced it out):
SELECT [TBL Addresses].Name, [TBL Addresses].Address1, [TBL Addresses].Address2, [TBL Addresses].Suburb, [TBL Addresses].Postcode, [TBL Addresses].DateRequested, [TBL Addresses].DateSent
FROM [TBL Addresses]
WHERE ((([TBL Addresses].Name) Like "*" & [Forms]![FRM: Data entry form]![Name] & "*")
AND (([TBL Addresses].Address1) Like "*" & [Forms]![FRM: Data entry form]![Address1] & "*")
AND (([TBL Addresses].Address2) Like "*" & [Forms]![FRM: Data entry form]![Address2] & "*")
AND (([TBL Addresses].Suburb) Like "*" & [Forms]![FRM: Data entry form]![Suburb] & "*")
AND (([TBL Addresses].Postcode) Like "*" & [Forms]![FRM: Data entry form]![Postcode] & "*"));
However, using this syntax I get no results.
I've tried setting the default value in the form to a wild card, but that doesn't work.
Presumably, I need to use some ORs rather than ANDs, but short of writing a dozen lines with every combination of fields possible, I'm not sure how to do this.
Also, not sure if this is changes things, but some of the fields in the table may be blank/null.
Thanks in advance, Helen
Form looks like:
Name:
Organisation:
Address1:
Address2:
Suburb:
Postcode:
And the user can enter data in as many fields as possible to narrow the search.
I've followed the below instructions to set up my form and query:
http://office.microsoft.com/en-au/access/HA011170771033.aspx?pid=CL100570041033
Which results in a query where the criteria refers back to the form, like below (I've added the wildcards so that the user can enter part of the name):
Like "*" & [Forms]![FRM: Data entry form]![Name] & "*"
SQL for whole query looks like (I've spaced it out):
SELECT [TBL Addresses].Name, [TBL Addresses].Address1, [TBL Addresses].Address2, [TBL Addresses].Suburb, [TBL Addresses].Postcode, [TBL Addresses].DateRequested, [TBL Addresses].DateSent
FROM [TBL Addresses]
WHERE ((([TBL Addresses].Name) Like "*" & [Forms]![FRM: Data entry form]![Name] & "*")
AND (([TBL Addresses].Address1) Like "*" & [Forms]![FRM: Data entry form]![Address1] & "*")
AND (([TBL Addresses].Address2) Like "*" & [Forms]![FRM: Data entry form]![Address2] & "*")
AND (([TBL Addresses].Suburb) Like "*" & [Forms]![FRM: Data entry form]![Suburb] & "*")
AND (([TBL Addresses].Postcode) Like "*" & [Forms]![FRM: Data entry form]![Postcode] & "*"));
However, using this syntax I get no results.
I've tried setting the default value in the form to a wild card, but that doesn't work.
Presumably, I need to use some ORs rather than ANDs, but short of writing a dozen lines with every combination of fields possible, I'm not sure how to do this.
Also, not sure if this is changes things, but some of the fields in the table may be blank/null.
Thanks in advance, Helen