Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When I want close 2 form.....

Status
Not open for further replies.

martine

Technical User
Jan 15, 2001
32
CA
Hi,

I have 2 form open and when the user close 1 form, I want just close the form but when he close the second form, i want he close the form AND Microsoft Access too.

I think in VB it's possible but I don't how do that....

Example:


If order_form is open then

close transport_form

else

close transport_form
close Microsoft Access


It's very important for me.......

Thanks

Martine




 
Hello,

I formOrder is open then
unload formTransport
else
application.quit
end if

Hope this helps...

Regards
Borg
 
Alternative:

Code:
If SysCmd(acSysCmdGetObjectState, acForm, "order_form") = acObjStateOpen Then 
    DoCmd.Close acForm, "transport_form"
Else
    Quit
End If

You don't need to discretely close transport_form in the Else part of this loop, as quitting Access will do that anyway.

Hope this helps.

[pc2]
 
ok mp9, i like your help

but the definition as what:


Dim req_order As String
Dim req_transport As String

req_order = "order_form"
req_transport = "transport_form"

It is ok?

Martine
 
I'm not sure that you really have to do it this way but I guess you could use your definitions like this:

Code:
Dim req_order As String
Dim req_transport As String
req_order = "order_form"
req_transport = "transport_form"
If SysCmd(acSysCmdGetObjectState, acForm, req_order) = acObjStateOpen Then 
    DoCmd.Close acForm, req_transport
Else
    Quit
End If

However, these first four lines are not really needed - my original post does exactly the same as the above, and with less code... surely a good thing? So unless you have a desperate need to declare those string variables... [smile] [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top