message if parameter not found

  • Thread starter Thread starter HYD2
  • Start date Start date
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
 
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
 
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
 
Back
Top