Ok, I have 3 parameter queries that run off command buttons. If I
click the Search Shop button, the default dialog pops up asking the
user to enter a shop name. Clicking the Search address button opens
the default dialog asking for Shop Address. They are different queries
at this point.
I suspected that this was the setup, but I was not sure.
Thank you for clarifying.
What I want in the end, is for the user to click 1 Search button, have
a custom dialog box pop up with all 3 options, be able to click an ok
button, and have those results appear back in the form.
For that to work the way you want it (for results to appear back on
frmCustomers), Form SearchBox will have to return only one row.
Query1 is set up to return many rows. frmCustomers only displays one
row's worth of information, and it would also have to be changed.
I apologize, but from the way I am reading your description, and
considering the way your forms are built, there appears to be a
contradition (one row display vs. a query that will return multiple
rows that you wish to display). Can you provide further
clarification?
I guess it's really a Filter By Form with a custom dialog box is what
I'm after. You can download what I'm working on at
http://perfectexposure.net/mine/headache.mdb.
What I'm after is to have the final results back in the form
frmCustomers. Does this help more?
Your OK button on Form SearchBox runs Macro2 using the On Click event.
Macro2 does OpenQuery on Query1. It is set for Datasheet View. This
is exactly like double clicking on Query1 yourself. It launches a
Datasheet View of the results for Query1.
Query1 is inaccessible. Any attempt to go into Design View or to
execute it shuts down MS Access. Clicking the OK button on Form
SearchBox does the same thing (shuts down MS Access).
When I use the Immediate Window to access its SQL indirectly, I find:
SELECT Customers.CustomerID
,Customers.CompanyName
,Customers.ContactName
,Customers.ContactTitle
,Customers.Address
,Customers.City
,Customers.Region
,Customers.ZipCode
,Customers.Country
,Customers.Phone
,Customers.Fax
FROM Customers
WHERE (((Customers.CustomerID)
LIKE [Forms]![SearchBox]![txtCustomerID] & "*")
AND ((Customers.Address)
LIKE [Forms]![SearchBox]![txtAddress] & "*")
AND ((Customers.ZipCode) Like [Forms]![SearchBox]![txtZip] &
"*"));
I removed the unneed () (MS Access can be pesky, at times).
SELECT Customers.CustomerID
,Customers.CompanyName
,Customers.ContactName
,Customers.ContactTitle
,Customers.Address
,Customers.City
,Customers.Region
,Customers.ZipCode
,Customers.Country
,Customers.Phone
,Customers.Fax
FROM Customers
WHERE (Customers.CustomerID
LIKE [Forms]![SearchBox]![txtCustomerID] & "*")
AND (Customers.Address
LIKE [Forms]![SearchBox]![txtAddress] & "*")
AND (Customers.ZipCode
LIKE [Forms]![SearchBox]![txtZip] & "*");
This expression will resolve only for data entered in all three fields
where that data does exist in Table Customers.
I deleted Query1, pasted the above into a new Query I named Query1
again, and now it will run.
When I run frmCustomers, click on Search, I see Form SearchBox launch.
I type in "G", "2", and "9". This brings up the first record, in a
Query's Datasheet View, because that it what this is all currently set
up to do.
I think you need to look at this slightly differently.
I cannot figure out any reason for frmCustomers to be first in this
sequence, it is only displaying one row and Query1 will be returning
many rows.
Step 0:
Create a backup of your database.
Step 1:
Create a copy of frmCustomers called frmCustomers2
Create a copy of SearchBox called SearchBox2
Create a copy of Query1 called Query2.
Step 2:
Change Macro2 to run OpenTable and designate the table to be
frmCustomers2 and set Datasheet View.
Step 3:
Change frmCustomers2 to have a Record Source of Query2.
Step 4:
Change Query2 so that all references to SearchBox are switched to
SearchBox2.
Step 5:
Make sure that the On Click event for the OK button on SearchBox2 is
still Macro2
Step 6:
Run SearchBox.
Enter your data (be careful that all three fields are entered and that
data matching at least one of the 7 row is entered).
Click Ok.
It should pop up frmCustomers showing the rows in question in what
amounts to a filter.
---------------------------
Only one set of data entered into SearchBox (L, 8, 9) will return more
than one row as far as i can tell.
---------------------------
It does occur to me that you didn't want multiple rows or any
appearance of datasheet view, in which case the design of Query1 needs
a review so that you can guarantee that it returns one row (which
means no LIKE operators).
Sincerely,
Chris O.