Close Open Form on Open New (1 Viewer)

scouser

Registered User.
Local time
Today, 06:31
Joined
Nov 25, 2003
Messages
767
Hi to all. I have the code below that opens frmSalesOrders when clicked from frmCustomers. I have other buttons that utilize code DoCmd.Close acForm, Me.Name and they function as required. In this instance frmCustomers remains open behind the form called frmSalesOrders.

Private Sub OrderID_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "frmSalesOrders", , , "OrderID = " & OrderID.Value
End Sub

Am I missing something obvious?
Thanks,
Phil.
 

scouser

Registered User.
Local time
Today, 06:31
Joined
Nov 25, 2003
Messages
767
I have put the following in the On_Load of frmSalesOrders. It works as required.

DoCmd.Close acForm, "frmCustomers"

Phil.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 22:31
Joined
Aug 30, 2003
Messages
36,125
I would have thought your code would work. Is the second form modal maybe?
 

MarkK

bit cruncher
Local time
Yesterday, 22:31
Joined
Mar 17, 2004
Messages
8,181
I would have expected your code to fail since you reference the value of a member of that form after you've closed it.
 

scouser

Registered User.
Local time
Today, 06:31
Joined
Nov 25, 2003
Messages
767
Hi. The form is not set to Modal. It is now working as previously stated. Thaks for taking time to review.
Phil
 

Users who are viewing this thread

Top Bottom