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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsgBox if combobox selection has no matching record 1

Status
Not open for further replies.

lastout

Programmer
Apr 12, 2002
84
US
I have a simple combobox that is used to find and bookmark a matching record on a form. I just used to the wizard to create it since it's easy and it works. The code is:

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[EntityID] = " & Str(Nz(Me![cmbSearchbyEntity], 5))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

My problem is that some of the items in the combobox do not have matching records in the table that the form is bound to. If there is no corresponding record for the selection the user makes in the combobox, I want to have a msgbox appear telling them so. Given the above code, I can't figure how to do it. Does anyone have a suggestion? Also, I don't understand why the If Not...Then statement in the code doesn't require an End If???

Thanks in advance! lastout (the game's not over till it's over)
 
Try this:

Set rs = Me.Recordset.Clone
rs.FindFirst "[EntityID] = " & Str(Nz(Me![cmbSearchbyEntity], 5))

if (rs.NoMatch) then
msgbox "entry not found"
else
do something else
end if
 
FancyPrairie,
Thanks a million. It works like a charm. lastout (the game's not over till it's over)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top