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!

Assistance with Queries 2

Status
Not open for further replies.

hwmueller

Technical User
Jan 16, 2001
155
Hi

I have a query that when run asks for the user to enter the name of the staff member whose details are required. When entered correctly the query runs fine. When no name or a wrong name is entered the query just produces a blank screen. I wish to change that so a message appears stating either "Please enter a name" or "That name is spelt incorrectly or doesn't exist". How do I do this??

Thanks

Hans
 
the easiest way is to make a recordset out of your query and if the recordcount = 0 then have your message pop up

alternatively, you can prepend "LIKE" and your query will come up with close matches.

Hope that helps.
 
Hi

I understand the logic behind your suggestion, however am a beginner with Access and dont quite follow how to exactly do what you suggested! Could you perhaps give me a rough step by step guide?

Thanks

Hans
 
dim db as database
dim rst as recordset
set db = currentdb()
set rst = db.openrecordset("select whatever ...... from the sql view of your query")
if rst.recordcount = 0 then
msgbox "There are no records that match your criteria"
exit sub
else
run your query ......
end if

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top