I have a form (F_ContractInfo) with primary key of ContractInfoID.
On the form is a button (ModRequestButton), that I want to open another form (SF_ModRequest) but have it linked to the F_ContractInfo via the ContractInfoID.
SF_ModRequest has record source set to T_ModRequest that has a field for ContractInfoID.
On the SF_ContractInfo
On the SF_ModRequest
I'm able to open the SF_ModRequest, and the ContractInfoID is set correctly.
When I close the form and hit the button again, it wants to add a new record.
How do I correct that?
On the form is a button (ModRequestButton), that I want to open another form (SF_ModRequest) but have it linked to the F_ContractInfo via the ContractInfoID.
SF_ModRequest has record source set to T_ModRequest that has a field for ContractInfoID.
On the SF_ContractInfo
Code:
Private Sub ModRequestButton_Click()
DoCmd.OpenForm _
FormName:="SF_ModRequest", _
DataMode:=acFormAdd, _
WindowMode:=acDialog, _
OpenArgs:=Forms![F_Contract]![SF_ContractInfo].[Form].[ContractInfoID]
End Sub
On the SF_ModRequest
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me![ContractInfoID] = Me.OpenArgs
End Sub
I'm able to open the SF_ModRequest, and the ContractInfoID is set correctly.
When I close the form and hit the button again, it wants to add a new record.
How do I correct that?