I would like to have my subform open with a command button (cmdDirectory) with OnClick macro (mDirectory.)
mDirectory
Form Name: frmDirectoryRpt
Data Mode: Add
I like the idea of using the macro because then the Rep will only have access to a new record. Everytime I direct the button to the macro, I lose the link to the member that the Rep will be updating. When you add a subform to a form, the wizard prompts you for the link. Is there a way to combine these two features so the command button stays with the current record on the form?
This is the code that I get if I just link it to the subform and don’t try to use the macro:
Private Sub cmdDirectory_Click()
On Error GoTo Err_cmdDirectory_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = “frmDirectoryRpt”
stLinkCriteria = “[JDE]=” & Me![JDE]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdDirectory_Click:
Exit Sub
Err_cmdDirectory_Click:
MsgBox Err.Description
Resume Exit_cmdDirectory_Click
End Sub