Altering Form Query

C

Chuck

I have a form (frmEmpInfo) that uses an underlying query as a record source.
In the query I refer one field's criteria to a form that remains open, for
example a switchboard that contains the employee number.

When the form is opened, it displays all records for the employee based upon
the employee number that is passed to the query.

I then have another form, (frmEmpLookup) that allows the user to see all
records of all employees, then select it for browsing the information. I
use the openform command and pass the record number and the employee number
to the query to open up the form frmEmpInfo. But it appears as a blank
form. It looks like the record number is passed, but the employee number
still appears to look for the switchboard number, not the one I pass.

So, in the command docmd.openform "frmEmpInfo",,,"[RecID] = xxx AND [EmpNum]
= xxx", does the [EmpNum] = xxx replace the criteria in the query in the
form that has been set to look elsewhere?
 
S

Steve Schapel

Chuck,

No. If your form is based on a query that already has a criteria set,
the Where Condition argument of the OpenForm method will not override
the criteria defined in the query itself.

There are a number of approaches you could take to solve this. Possibly
the simplest is to remove the criteria from the query, and use a Where
Condition in the OpenForm that you use to open the frmEmpLookup form
from the switchboard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top