msg box code

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
 
D

Douglas J. Steele

If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Record was not found"
End If
 
D

Dirk Goldgar

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
 

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

Top