Hey all,
I posted a few days ago in an attempt to try a find out how to display a 'No records found' message when a query turns up no criteria-matching results. I got two replies. Unfortunately, neither worked for me (although I'm sure it did for them).
Basically, a form (displaying the query's results) is opened via a command button on the system's switchboard. The button runs a macro to close the switchboard and open the form. The query form is called FrmQryClient, and the query itself is simply QryClient.
This is the current code used by the command button:
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Dim stDocName As String
stDocName = "CloseSwitchboardOpenFrmQryClient"
DoCmd.RunMacro stDocName
If (Form_FrmQryClient.RecordCount = 0) Then MsgBox "No records are available"
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub
Because I am fairly unfamiliar with Visual Basic, I am finding it hard to use the terminology. At present, this code brings up the message 'Object required'. If I do not specify the Form_FrmQryClient then the MsgBox is displayed every time the form is opened, whether results have been found or not.
Any ideas would be greatly appreciated!
I posted a few days ago in an attempt to try a find out how to display a 'No records found' message when a query turns up no criteria-matching results. I got two replies. Unfortunately, neither worked for me (although I'm sure it did for them).
Basically, a form (displaying the query's results) is opened via a command button on the system's switchboard. The button runs a macro to close the switchboard and open the form. The query form is called FrmQryClient, and the query itself is simply QryClient.
This is the current code used by the command button:
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Dim stDocName As String
stDocName = "CloseSwitchboardOpenFrmQryClient"
DoCmd.RunMacro stDocName
If (Form_FrmQryClient.RecordCount = 0) Then MsgBox "No records are available"
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub
Because I am fairly unfamiliar with Visual Basic, I am finding it hard to use the terminology. At present, this code brings up the message 'Object required'. If I do not specify the Form_FrmQryClient then the MsgBox is displayed every time the form is opened, whether results have been found or not.
Any ideas would be greatly appreciated!