A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

message if parameter not found



 
 
Thread Tools Display Modes
  #1  
Old July 23rd, 2009, 04:20 PM posted to microsoft.public.access.forms
HYD2
external usenet poster
 
Posts: 2
Default message if parameter not found

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

  #2  
Old July 23rd, 2009, 07:16 PM posted to microsoft.public.access.forms
fredg
external usenet poster
 
Posts: 4,386
Default message if parameter not found

On Thu, 23 Jul 2009 08:20:12 -0700, HYD2 wrote:

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


--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #3  
Old July 24th, 2009, 02:26 PM posted to microsoft.public.access.forms
HYD2
external usenet poster
 
Posts: 2
Default message if parameter not found



"HYD2" wrote:

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
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:33 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.