edgarchado
Technical User
Hi to All,
I am a new user to access and trying to build a small application for my Company.
I have a Report which shows all client orders. I also have a form with a command button which I use to filter the results of the report by date. If I enter a date for which an order exists I have no problem, and I get the roport for that date. If I enter a date for which there are no orders I get a report with an error value in the date field. What I need, is for the form to display a message saying "There are no orders for (the date entered by user)" and return to the form to enter a new date.
The code for my command button is:
Private Sub Command1_Click()
On Error GoTo PROC_ERR
Dim strFilter As String
If strFilter = "" Then
strFilter = "[Date] = [Delivery Date]"
Else
MsgBox "No Orders for that Date"
End If
DoCmd.OpenReport "Reporte_Pedidos", acViewPreview, , strFilter
PROC_EXIT:
Exit Sub
PROC_ERR:
If Err.Number = 2501 Then
DoCmd.OpenForm "Home"
End If
Resume PROC_EXIT
End Sub
Thank you very much.
I am a new user to access and trying to build a small application for my Company.
I have a Report which shows all client orders. I also have a form with a command button which I use to filter the results of the report by date. If I enter a date for which an order exists I have no problem, and I get the roport for that date. If I enter a date for which there are no orders I get a report with an error value in the date field. What I need, is for the form to display a message saying "There are no orders for (the date entered by user)" and return to the form to enter a new date.
The code for my command button is:
Private Sub Command1_Click()
On Error GoTo PROC_ERR
Dim strFilter As String
If strFilter = "" Then
strFilter = "[Date] = [Delivery Date]"
Else
MsgBox "No Orders for that Date"
End If
DoCmd.OpenReport "Reporte_Pedidos", acViewPreview, , strFilter
PROC_EXIT:
Exit Sub
PROC_ERR:
If Err.Number = 2501 Then
DoCmd.OpenForm "Home"
End If
Resume PROC_EXIT
End Sub
Thank you very much.