I have created the following code to open the appropriate linked record in a related table or to create a new record if a record does not exist.
Dim ProgType As String
ProgType = [Forms]![frmtest].[ProgramType]
If ProgType = "Competitive" Then
If IsNull(DLookup("[Grant#]", "tblCT", "[Grant#] = " & [Forms]![frmtest].[ID])) Then
If MsgBox("Create a new tracking record?", vbOKCancel) = vbOK Then
DoCmd.OpenForm "frmCT", acNormal, , , acFormAdd
Else
MsgBox ("Action Cancelled")
End If
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "FrmCT", acNormal, , "[Grant#] = " & [Forms]![frmtest].[ID]
End If
End If
The issue is that if a new record is created, I want it to be created with the key value [tblCT].[Grant#] egual to the value of the record open in the original form [tblSum].[Grant#] in (frmtest). Can I do this in DoCmd.OpenForm acFormAdd or by setting a default value in the form that is being called? I haven't found anything that will work.
Thanks.
Dim ProgType As String
ProgType = [Forms]![frmtest].[ProgramType]
If ProgType = "Competitive" Then
If IsNull(DLookup("[Grant#]", "tblCT", "[Grant#] = " & [Forms]![frmtest].[ID])) Then
If MsgBox("Create a new tracking record?", vbOKCancel) = vbOK Then
DoCmd.OpenForm "frmCT", acNormal, , , acFormAdd
Else
MsgBox ("Action Cancelled")
End If
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "FrmCT", acNormal, , "[Grant#] = " & [Forms]![frmtest].[ID]
End If
End If
The issue is that if a new record is created, I want it to be created with the key value [tblCT].[Grant#] egual to the value of the record open in the original form [tblSum].[Grant#] in (frmtest). Can I do this in DoCmd.OpenForm acFormAdd or by setting a default value in the form that is being called? I haven't found anything that will work.
Thanks.