msg box code

  • Thread starter Thread starter RipperT
  • Start date Start date
R

RipperT

Hello,

I've used the combo box wizard to create a combo box that looks up records.
It's after_update event code looks like this:

Private Sub Combo16_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[InmateId] = '" & Me![Combo16] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

What could I add to generate a message box that says "record was not found"

Many thanx,

Ripper
 
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Record was not found"
End If
 
Douglas J. Steele said:
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Record was not found"
End If

But if this code is an an MDB file, not an ADP, you need to check the
NoMatch property instead of EOF (no matter what the wizard says):

If rs.NoMatch Then
MsgBox "Record was not found"
Else
Me.Bookmark = rs.Bookmark
End If
 
Back
Top