Create error msg box

NikkCol

New member
Local time
Today, 14:13
Joined
Nov 16, 2011
Messages
8
How do I create a msg box whenever someone enter a project number that doesnt exist. Currently it just pull up the form or report with empty information.
I would prefer to have it just popup a message that says this project number doesnt exist. Try again.

I'm not sure how to create the macro or where to place it? Need help
 
I'm not sure how you would do that using a Macro, but the following code in the Form's On Load event will do what you are after;
Code:
    If Me.Recordset.RecordCount = 0 Then
        MsgBox "Sorry there where no records matching that criteria"
        DoCmd.Close
    End If
 
I just tried what you suggested but didnt get the message.
Im putting this code in the Code Builder section correct?
 
it would be under form properties-->event tab-->on load, then click cod builder and place the code there.

Depending on how you have users input the project number, you could simply use a combo box that refers to a query with only the existing project numbers. This way a user can only select a project number which exists to begin with.
 
Yes..I did this. But when I test by entering a incorrect project number when it asked no message appear. Not sure what I am doing wrong?
 
Are you able to post a copy of your DB ('07 or earlier for preference)?
 

Users who are viewing this thread

Back
Top Bottom