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

Need MsgBox to state data entered not found in DB

Status
Not open for further replies.

bvbowes

Programmer
Oct 12, 2006
21
US
I have a form that opens data in another form. But if I enter data that isn't in the database, it doesn't do anything, so I want a msgbox telling the user that they entered a case number that isn't in the database.

Maybe a dlookup, I'm not sure? Here's the code so far.
*******************************************************

Private Sub cmdOpenCaseinMainEntry_Click()

Dim rs As DAO.Recordset

If Trim(Me!txtOpenCase & " ") = "" Then
MsgBox "Please enter a case number", vbOKOnly, "Oops..."

Else 'this is where I need some code for a msgbox

Set rs = Forms!frmMainEntry.RecordsetClone
rs.FindFirst "CaseNumber=" & Me!txtOpenCase

If Not rs.NoMatch Then MsgBox "Case number not found." 'Forms!frmMainEntry.Bookmark = rs.Bookmark"

DoCmd.Close

End If
End

End Sub
 
Im sure there's more to this but for now - NoMatch returns True if the desired record was not found.

Try:
If rs.NoMatch Then MsgBox "Case number not found."

Let them hate - so long as they fear... Lucius Accius
 
Oh...I had the Not in there on accident, thanks. Just needed a second pair of eyes, thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top