I have a form with a command button that when clicked on opens a second form. I need a message box to come up when the second form returns no records. I need the code to be on the command button Here is what i have that does not work
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Second frm"
stLinkCriteria = "[Person_ID]=" & Me![Person_ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
If Me.Recordset.RecordCount = 0 Then
DoCmd.Close
MsgBox "There are no details for this record! See Help button for details"
End If
Exit_Command10_Click:
Exit Sub
Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click
End Sub
Not sure why this doesn't work, any suggestion are welcome, thanks
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Second frm"
stLinkCriteria = "[Person_ID]=" & Me![Person_ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
If Me.Recordset.RecordCount = 0 Then
DoCmd.Close
MsgBox "There are no details for this record! See Help button for details"
End If
Exit_Command10_Click:
Exit Sub
Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click
End Sub
Not sure why this doesn't work, any suggestion are welcome, thanks