Combo box filter before form opens

M

m stroup

frmSearchType with cboType and cmdOpenForm which opens frmEntryEdit.
frmEntryEdit uses cboEntryNum to allow user to select from the filtered
records.
This is working correctly, however if no records fit the filter, I get an
open frmEntryEdit, with no records in the cboEntryNum. I would rather have a
message box that states "No Data fits the criteria", than have frmEntry Edit
open. Is this possible?
 
M

Marshall Barton

m said:
frmSearchType with cboType and cmdOpenForm which opens frmEntryEdit.
frmEntryEdit uses cboEntryNum to allow user to select from the filtered
records.
This is working correctly, however if no records fit the filter, I get an
open frmEntryEdit, with no records in the cboEntryNum. I would rather have a
message box that states "No Data fits the criteria", than have frmEntry Edit
open.

One way would be to use an If statement with a DLookup to
see if there is a match or not. Then you can skip opening
the form.

Another way would be for the form's Load event to check its
RecordCount and Cancel the event if the count is 0. In this
case the button's code probably should use error handling to
ignore the 2501 error.
 

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