Parameter prompt with form recordsource using combobox criteria

E

EdA

I have a form that uses a combobox (EmployeeID) value as it's criteria in the
record source query. The first time the form is opened the user is prompted
to enter a parameter value (for the EmployeeID combobox). If I hit cancel
and then go into design view and then back to form view, the form works fine
and I do not get prompted for a parameter.

Any ideas how to overcome this?
 
A

Allen Browne

I think you created a query with parameter such as:
[Forms].[frmEmployee].[cboEmployeeID]
so it reads the value from the combo on the form, and they used that query
as the RecordSource for that form?

I'm going to assume that cboEmployeeID is unbound, i.e. it is merely used to
filter the form. If so, an alternative would be to leave the parameter out
of the query, and use the AfterUpdate event procedure of the combo to either
find the record (if there's only one possible match), or to filter the form
(if there could be several records for that employee.)

Here's an example of code that uses an unbound combo to jump to the one
match:
Using a Combo Box to Find Records
at:
http://allenbrowne.com/ser-03.html

Here's an example of building a filter string for several filter boxes:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html
(That last one is more complex than you need. It's a technique that's worth
knowing, but post back if it's too much.)
 
E

EdA

Yes, that is exactly what I am doing. I like your solution also because I
will have more than just my single record so i can advance through the
various employees by using the record navigation buttons which will give
additional flexibility in my form.

Thank you.

Allen Browne said:
I think you created a query with parameter such as:
[Forms].[frmEmployee].[cboEmployeeID]
so it reads the value from the combo on the form, and they used that query
as the RecordSource for that form?

I'm going to assume that cboEmployeeID is unbound, i.e. it is merely used to
filter the form. If so, an alternative would be to leave the parameter out
of the query, and use the AfterUpdate event procedure of the combo to either
find the record (if there's only one possible match), or to filter the form
(if there could be several records for that employee.)

Here's an example of code that uses an unbound combo to jump to the one
match:
Using a Combo Box to Find Records
at:
http://allenbrowne.com/ser-03.html

Here's an example of building a filter string for several filter boxes:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html
(That last one is more complex than you need. It's a technique that's worth
knowing, but post back if it's too much.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

EdA said:
I have a form that uses a combobox (EmployeeID) value as it's criteria in
the
record source query. The first time the form is opened the user is
prompted
to enter a parameter value (for the EmployeeID combobox). If I hit cancel
and then go into design view and then back to form view, the form works
fine
and I do not get prompted for a parameter.

Any ideas how to overcome this?
 

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