Creating a Find Field on a Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that tracks data on sale items. Each sale item is given a
tracking number. How do I create an interface so I can type in a tracking
number and the record in question will automatically pop up?
 
You will need to have some basic understanding of VBA code to achieve this.

Add an unbound text box on your form. In its AfterUpdate event procedure,
use DLookup() to find which product is is associated with, and then
FindFirst in the RecordsetClone of the form to bring that product up.

For help with using DLookup(), see:
Getting a value from a table: DLookup()
at:
http://allenbrowne.com/casu-07.html

For an example of finding the record in the form's clone set and bringing it
up in the form, see:
Using a Combo Box to Find Records
at:
http://allenbrowne.com/ser-03.html
 
One option is to place an unbound text field on a form and add the
following code to its _AfterUpdate event. The advantage is that if
multiple records are returned (for example if you enter a phone number),
all of the records matching that value will be found.

Private Sub txtGotoRecord_AfterUpdate()

Me.FilterOn = False
Me.Filter = "lngTransportId = " & Me.txtGotoRecord
Me.FilterOn = True
If Me.NewRecord = True Then MsgBox ([Message here that indicates
that the record was not found])

End Sub
 
For another approach, you might set up a form with all the fields displaying
the information you'd like to see for each sale item. Then set up another
form with a combo box for the tracking number. You could then set up the
first form as a subform within the second form.

Oli
04.03.06 07.04 hst
 
Back
Top