message if parameter not found

H

HYD2

I have a form which gets data from a parameter query. I want to send a
message if the results of the parameter is null, before is opens the form
(which will be blank).
I found this helpful information on this site and has worked for several
other forms, but no matter what I do, this does not seem to work: It stops on
the If statement.
*** FYI - the query name is correct

Private Sub Form_Load()

If DCount("*", "Prod Find RBT Number qry") = 0 Then

MsgBox "Robot number not found on that System"

DoCmd.Close

Else
DoCmd.OpenForm "Prod Find RBT Number form"

End If



End Sub
 
F

fredg

I have a form which gets data from a parameter query. I want to send a
message if the results of the parameter is null, before is opens the form
(which will be blank).
I found this helpful information on this site and has worked for several
other forms, but no matter what I do, this does not seem to work: It stops on
the If statement.
*** FYI - the query name is correct

Private Sub Form_Load()

If DCount("*", "Prod Find RBT Number qry") = 0 Then

MsgBox "Robot number not found on that System"

DoCmd.Close

Else
DoCmd.OpenForm "Prod Find RBT Number form"

End If



End Sub

Wrong event.
Code the form's Open event:

If Me.RecordSetClone.RecordCount = 0 Then
MsgBox "Robot number not found on that System"
Cancel = True
End If
 
H

HYD2

HYD2 said:
I have a form which gets data from a parameter query. I want to send a
message if the results of the parameter is null, before is opens the form
(which will be blank).
I found this helpful information on this site and has worked for several
other forms, but no matter what I do, this does not seem to work: It stops on
the If statement.
*** FYI - the query name is correct

Private Sub Form_Load()

If DCount("*", "Prod Find RBT Number qry") = 0 Then

MsgBox "Robot number not found on that System"

DoCmd.Close

Else
DoCmd.OpenForm "Prod Find RBT Number form"

End If



End Sub

Thank you Fred, it works Great.
I am surprised that it worked on my other forms.

HYD2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top