Help with message box when no record found

JackieEVSC

Registered User.
Local time
Today, 08:30
Joined
Feb 24, 2012
Messages
26
I have a db where users can search for various things, which could be alpha, numeric, or alphanumeric. Right now, the code stands as such:

DoCmd.Close acForm, "frm_RepairMenu"
On Error GoTo fErr
DoCmd.OpenForm "frm_RepairInfo-Notes"
Exit Sub
fErr:
DoCmd.OpenForm "frm_RepairMenu", View:=acNormal, OpenArgs:="SearchRep"

If a record is found or if the search is canceled, it works perfectly. However, if no records are found, the db currently displays a screen with a header and no information. At this point, you have to quit Access, then reopen the db to search again. (I have all the control buttons disabled in the database so that they don't close a form and have no way to navigate.)

I need a message box to tell the user "No records found.", and when "ok" is clicked, they go back to the repair menu on the search repairs tab. I have searched these forums (and the internet) for help, and I can't seem to find the answer. I know it's a simple thing to do, I just can't figure it out! Can someone help me with this? Thanks.
 
The code you posted is not complete, and it does not perform a search. It simply closes and opens forms.
 
You need to do a DCount into the datasource the form is built on. If the DCount returns 0 then you show your message box, if not, you run the OpenForm command.
 
Mark ... It's not apparent, but the form is based on a query.

Plog ... Thanks, I'll give that a try.
 
You could also reinstate the control box on the popup form, to enable the close button to work.

Note that your problem is that if you have:
- a form with no records AND
- a non updateable form

then you will see a blank form with no working controls, which is what you have.
 

Users who are viewing this thread

Back
Top Bottom