Find records using form fields

  • Thread starter Thread starter blacky
  • Start date Start date
B

blacky

I would like to do the following:

I have a form Main that is associated with a table Data. I would like to
have a button or some other control in this form that it will be used by
the user to enter a field of the form and find all the records that contain
the specific field entered (for example if he wants to find all records that
contain as City field= London then after using this button all these records
to be displayed). The user should be able to enter any of the existing
fields on the form to find records and not only the CompanyID field for
example. Can anyone help me to produce this code?

Thank you in advance

blacky
 
AFAIK if the form is bound to the data object, you can not use the bound
fields for anything but data entry. However a good workaround is to place a
small button next to each field from which you would like the user to be
able to look up or filter values. In the button click even, use this code
example:

Me.Filter = "[MyField] Like '" & _
InputBox("Enter Branch Code Filter", _
"Define Filter") & "*'"
Me.FilterOn = True

I'm not a big fan of the inputbox myself, but it does a good job for these
types of requirements. Another option would be to create a hidden unbound
field for each bound field and swap the hidden attribute between bound and
unbound fields when you want to be able to look up values. This does cause
some project maintenance considerations and may be more work that it's
worth.

Hope this helps,
- Glen
 
Back
Top