I have an Access form with a button on it that opens a sub form. I cannot get the sub form to open linking to the record id on the first form. Any suggestions?
Here is the code I use to open the sub form:
Private Sub Command178_Click()
On Error GoTo Err_Command178_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Contact"
stLinkCriteria = "[EMPI]=" & "'" & Me![EMPI] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command178_Click:
Exit Sub
Err_Command178_Click:
MsgBox Err.Description
Resume Exit_Command178_Click
End Sub
Here is the code I use to open the sub form:
Private Sub Command178_Click()
On Error GoTo Err_Command178_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Contact"
stLinkCriteria = "[EMPI]=" & "'" & Me![EMPI] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command178_Click:
Exit Sub
Err_Command178_Click:
MsgBox Err.Description
Resume Exit_Command178_Click
End Sub