Searching for records

  • Thread starter Thread starter BigNasty
  • Start date Start date
B

BigNasty

I have a form that has three combo boxes on it. Based on what the users
selects a query is generated and the results are displayed in a
datasheet.

I would like the user to be able to perform a search for a list of
records, click on the record in the datasheet and be presented with the
record in the original form.

Can any one provide some high level details on how I would do this.
 
BigNasty said:
I have a form that has three combo boxes on it. Based on what the users
selects a query is generated and the results are displayed in a
datasheet.

I would like the user to be able to perform a search for a list of
records, click on the record in the datasheet and be presented with the
record in the original form.


Check that each combo has a value and if it does, add it to
a where string. Then use the OpenForm method's
WhereCondition argument to open your data form.

The general idea of the code:

If Not IsNull(Me.combo1) Then
strWhere = " AND field1 = " & Me.combo1 'number field
End If
If Not IsNull(Me.combo2) Then
strWhere = " AND field2 = """ & Me.combo2 & """" 'text
End If
If Not IsNull(Me.combo3) Then
strWhere = " AND field3 = " & _
Format(Me.combo3, "\#m\/d\/yyyy\#") 'date
End If
DoCmd.OpenForm "theform", _
WhereCondition:= Mid(strWhere, 6)
 

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

Back
Top