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

Access97

Status
Not open for further replies.

Goodloe

Programmer
Sep 4, 2001
25
US
Good morning: I'm working on a project in Access97.
In the Parameter Query in the Criteria Cell, I have it set
to where if you are looking for a particular last name
(Like[Enter Last Name]&*), and if you enter a letter of the
alphabet it will display everything related to that letter.

Here's where I need your help. If the name or letter of the
alphabet is not in the table or database, I would like a message to come up saying that the name is not in the database or table. How would I go about displaying a message
box? Can you also give a syntax example of the procedures?
 
In a query, you really can't

Would you could do, is run the SQL statement in VBA first and open a recordset. If the recordset doesn't return records, display your message box.

Dim DBS
Dim RST
Dim strSQL
strSQL = "Your SQL statement"
Set DBS = currentDB
Set rst = dbs.openrecordset(strSQL)
rst.movelast
If not rst.eof and rst.bof then
'do something
Else
msgbox "No matches were found"
End If


As an alternative, you could make a report based on your query. Reports have a "On No Datas" event which you could use to display your message box.

Tyrone Lumley
augerinn@gte.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top