Parameter prompt with form recordsource using combobox criteria

Parameter prompt with form recordsource using combobox criteria

Post by RWRB » Fri, 12 Dec 2008 00:02:27


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?
 
 
 

Parameter prompt with form recordsource using combobox criteria

Post by Allen Brow » Fri, 12 Dec 2008 15:33:36

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://www.yqcomputer.com/

Here's an example of building a filter string for several filter boxes:
Search form - Handle many optional criteria
at:
http://www.yqcomputer.com/
(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
Tips for Access users - http://www.yqcomputer.com/
Reply to group, rather than allenbrowne at mvps dot org.