Open form from another form

jsic1210

Registered User.
Local time
Yesterday, 21:21
Joined
Feb 29, 2012
Messages
188
Hello everyone, I'm trying to open one form from another. The problem is, from the first form, frmCustomer, I am creating a new record. When I click the button, the new form, frmContractsForm, opens, but to a new record. Since the parent form of frmContractsForm, I want it to open based on its primary key, CustomerID. Here is my code:

'Create Open Item for New Customer
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm "frmContractForm", , , "CustomerID=" & Me.CustomerID

I know it's a new record in frmCustomer, but I thought the acCmdSaveRecord would solve that problem. Thanks in advance!
 
Try doing a Requiry, on first form, before you open the new form.
 
Try saving the record and then next Form.

Simon
 
@Simon_MT: Is there a better way to save it than
DoCmd.RunCommand acCmdSaveRecord?

@PNGBill: When I requery, it opens a different record. Here is my code:
DoCmd.RunCommand acCmdSaveRecord
Me.Requery
DoCmd.OpenForm "frmContractForm", , , "CustomerID=" & Me.CustomerID

Thanks!
 
Check the Link Master Child properties and also the Add New Record properties of your new form to open.

You can set a form to open expecting a new record to be added which may be the setting you have.
 
Okay, for some reason, my code seems to be working now. I swear I tried this before:
Code:
Private Sub btnOpenItem_Click()
        DoCmd.RunCommand acCmdSaveRecord
        DoCmd.OpenForm "frmContractForm", , , "CustomerID=" & Me.CustomerID
End Sub
Thanks for the help!
 

Users who are viewing this thread

Back
Top Bottom