Prevent from loading

  • Thread starter Thread starter Pietro
  • Start date Start date
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
 
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.
 
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
 
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

Back
Top