B
BrettS
Hi, I've been using rs.FindFirst to search by two criteria using the
following code:
Private Sub FilterSamp_AfterUpdate()
On Error GoTo err_Handler
Dim rs As DAO.Recordset
If Not IsNull(Me.FilterSamp) Then
If Me.Dirty Then
Me.Dirty = False
End If
Set rs = Me.RecordsetClone
rs.FindFirst "[RE Job #] = """ & Me![RE Job #] & """ and [Task Samp
#] = " & Me.FilterSamp
If rs.NoMatch Then
MsgBox "Not found: Try Another Record"
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
Me.FilterSamp = ""
Me.Refresh
exit_Here:
Exit Sub
err_Handler:
MsgBox Err.Number & ": " & Err.Description, vbCritical, "***ERROR***"
End Sub
This is working great, my question is whether or not I can use this to
search by three criteria. It seems the answer is no, because when I try to
add this to the line for another form:
rs.FindFirst "[RE Job #] = """ & Me.[RE Job #] & """ and [Task Samp #] = " &
Me.[Samp ID #] and [Meas ID #] = " & Me.[Meas ID #]
when I actually use the combobox it edits the line and puts a " at the end,
and also seems to put it into its own expression? I'm only marginally
functional in VB so I'm not sure, but the second and gets capitalized and
turns into the navy blue text, so I'm assuming that is what is happening. Is
there any way to get around this? Or is two fields the maximum you can use
for rs.FindFirst?
following code:
Private Sub FilterSamp_AfterUpdate()
On Error GoTo err_Handler
Dim rs As DAO.Recordset
If Not IsNull(Me.FilterSamp) Then
If Me.Dirty Then
Me.Dirty = False
End If
Set rs = Me.RecordsetClone
rs.FindFirst "[RE Job #] = """ & Me![RE Job #] & """ and [Task Samp
#] = " & Me.FilterSamp
If rs.NoMatch Then
MsgBox "Not found: Try Another Record"
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
Me.FilterSamp = ""
Me.Refresh
exit_Here:
Exit Sub
err_Handler:
MsgBox Err.Number & ": " & Err.Description, vbCritical, "***ERROR***"
End Sub
This is working great, my question is whether or not I can use this to
search by three criteria. It seems the answer is no, because when I try to
add this to the line for another form:
rs.FindFirst "[RE Job #] = """ & Me.[RE Job #] & """ and [Task Samp #] = " &
Me.[Samp ID #] and [Meas ID #] = " & Me.[Meas ID #]
when I actually use the combobox it edits the line and puts a " at the end,
and also seems to put it into its own expression? I'm only marginally
functional in VB so I'm not sure, but the second and gets capitalized and
turns into the navy blue text, so I'm assuming that is what is happening. Is
there any way to get around this? Or is two fields the maximum you can use
for rs.FindFirst?