Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find a record using 2 criteria

Status
Not open for further replies.

1stTimeOut

Technical User
Mar 2, 2007
6
US
My form pulls from a table containing two records
[MDN NPA-NXX] with a date of 01/01/98
[MDN NPA-NXX] with a date of 01/03/99

I'm using a combo box to find the records. It searches fine, but will only populate the form with the first record even if I select the second record from the combo list. How can I select a specific record to populate the form?

Here's the query:
SELECT [altMASTER MDNMIN].[MDN NPA-NXX] FROM [altMASTER MDNMIN] ORDER BY [altMASTER MDNMIN].[MDN NPA-NXX];

Here's the event code:
Private Sub comboMDNsearch_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[MDN NPA-NXX] = '" & Me![comboMDNsearch] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me![comboMDNsearch] = Null
End Sub

I appreciate your expertise, and thanks!
 
re you sure that is a MDN NPA-NXX text field?

[tt]rs.FindFirst "[MDN NPA-NXX] = '" & Me![comboMDNsearch] & "'"[/tt]

You need hash (#) as the delimiter for dates. Also, it would be as well to format the date, if the field is a date:

[tt]Format(Me![comboMDNsearch],"yyyy-mm-dd")[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top