Prevent from loading

P

Pietro

Hi,
How can i prevent the form CAP from loading in the following code:

dim a as single
If [Forms]![sw]![FRM] <> "cap" And [Status] = "Open" Then
a = MsgBox("You cannot handle more than one case on the same time", 16,
"Improper action")
The form CAP is not loaded
end if
 
D

Douglas J. Steele

Assuming that you're trying to do this from outside the form CAP, you simply
don't load the form:

If [Forms]![sw]![FRM] <> "cap" And [Status] = "Open" Then
MsgBox "You cannot handle more than one case on the same time", 16,
"Improper action"
Else
DoCmd.OpenForm "CAP"
End If

Note that there's no need to declare the variable a and use the function
version of MsgBox since don't care what button they click on in the message
box.
 
P

Pietro

Thank you for your reply...
I want to put this event in the form 'cap' load...

Douglas J. Steele said:
Assuming that you're trying to do this from outside the form CAP, you simply
don't load the form:

If [Forms]![sw]![FRM] <> "cap" And [Status] = "Open" Then
MsgBox "You cannot handle more than one case on the same time", 16,
"Improper action"
Else
DoCmd.OpenForm "CAP"
End If

Note that there's no need to declare the variable a and use the function
version of MsgBox since don't care what button they click on in the message
box.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Pietro said:
Hi,
How can i prevent the form CAP from loading in the following code:

dim a as single
If [Forms]![sw]![FRM] <> "cap" And [Status] = "Open" Then
a = MsgBox("You cannot handle more than one case on the same time", 16,
"Improper action")
The form CAP is not loaded
end if
 
D

Douglas J. Steele

What is Status: a control on the form? Will there only be a single one?

You might be better off using the form's Open event. There, you simply set
Cancel = True if you don't want the form to complete opening.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Pietro said:
Thank you for your reply...
I want to put this event in the form 'cap' load...

Douglas J. Steele said:
Assuming that you're trying to do this from outside the form CAP, you
simply
don't load the form:

If [Forms]![sw]![FRM] <> "cap" And [Status] = "Open" Then
MsgBox "You cannot handle more than one case on the same time", 16,
"Improper action"
Else
DoCmd.OpenForm "CAP"
End If

Note that there's no need to declare the variable a and use the function
version of MsgBox since don't care what button they click on in the
message
box.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Pietro said:
Hi,
How can i prevent the form CAP from loading in the following code:

dim a as single
If [Forms]![sw]![FRM] <> "cap" And [Status] = "Open" Then
a = MsgBox("You cannot handle more than one case on the same time", 16,
"Improper action")
The form CAP is not loaded
end if
 

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