nuttychick
Registered User.
- Local time
- Today, 10:08
- Joined
- Jan 16, 2004
- Messages
- 84
Hope someone can help
I have a database that records different types of Hardware Calls made.
There are reports based on crosstab queries.
I have a form that the user can specify the dates to run the report from, before or between. The code I have used to do this is below.
This works fine.
However I would now like to add a combo box with a list of the reports available, so the user can specify the dates and also the report they want to see.
I have changed the stdocName to read from the combo list. However if I select a report and run the cmd I get this error.
Run-time error '3070'
The Microsoft Jet database engine does not recognise '[forms]![DateSelection]![Date1]' as a valid field name or operator.
The quoted part differs depending what dates you enter.
How do I tell the cmd button to open the report specified in the combo and use the date criteria set.
If I use the dbug and step into then I can see that the code is picking up the correct report.
Any help would be much appreciated.
Private Sub Command16_Click()
'On Error GoTo Err_Command16_Click
Dim stDocName As String
stDocName = [Forms]![DateSelection]![Report List]
If IsNull([Forms]![DateSelection]![Date1]) And IsNull([Forms]![DateSelection]![Date2]) Then
MsgBox "There are no dates entered", vbOKOnly
End If
If Not IsNull([Forms]![DateSelection]![Date1]) And IsNull([Forms]![DateSelection]![Date2]) Then
DoCmd.OpenReport stDocName, acPreview, , "[HWCallDate] >= [Forms]![DateSelection]![Date1]"
End If
If IsNull([Forms]![DateSelection]![Date1]) And Not IsNull([Forms]![DateSelection]![Date2]) Then
DoCmd.OpenReport stDocName, acPreview, , "[HWCallDate] <= [Forms]![DateSelection]![Date2]"
End If
If Not IsNull([Forms]![DateSelection]![Date1]) And Not IsNull([Forms]![DateSelection]![Date2]) Then
DoCmd.OpenReport stDocName, acPreview, , "[HWCallDate] >= [Forms]![DateSelection]![Date1] and [HWCallDate] <= [Forms]![DateSelection]![Date2]"
End If
Exit_Command16_Click:
Exit Sub
'Err_Command16_Click:
MsgBox Err.Description
Resume Exit_Command16_Click
End Sub
I have a database that records different types of Hardware Calls made.
There are reports based on crosstab queries.
I have a form that the user can specify the dates to run the report from, before or between. The code I have used to do this is below.
This works fine.
However I would now like to add a combo box with a list of the reports available, so the user can specify the dates and also the report they want to see.
I have changed the stdocName to read from the combo list. However if I select a report and run the cmd I get this error.
Run-time error '3070'
The Microsoft Jet database engine does not recognise '[forms]![DateSelection]![Date1]' as a valid field name or operator.
The quoted part differs depending what dates you enter.
How do I tell the cmd button to open the report specified in the combo and use the date criteria set.
If I use the dbug and step into then I can see that the code is picking up the correct report.
Any help would be much appreciated.
Private Sub Command16_Click()
'On Error GoTo Err_Command16_Click
Dim stDocName As String
stDocName = [Forms]![DateSelection]![Report List]
If IsNull([Forms]![DateSelection]![Date1]) And IsNull([Forms]![DateSelection]![Date2]) Then
MsgBox "There are no dates entered", vbOKOnly
End If
If Not IsNull([Forms]![DateSelection]![Date1]) And IsNull([Forms]![DateSelection]![Date2]) Then
DoCmd.OpenReport stDocName, acPreview, , "[HWCallDate] >= [Forms]![DateSelection]![Date1]"
End If
If IsNull([Forms]![DateSelection]![Date1]) And Not IsNull([Forms]![DateSelection]![Date2]) Then
DoCmd.OpenReport stDocName, acPreview, , "[HWCallDate] <= [Forms]![DateSelection]![Date2]"
End If
If Not IsNull([Forms]![DateSelection]![Date1]) And Not IsNull([Forms]![DateSelection]![Date2]) Then
DoCmd.OpenReport stDocName, acPreview, , "[HWCallDate] >= [Forms]![DateSelection]![Date1] and [HWCallDate] <= [Forms]![DateSelection]![Date2]"
End If
Exit_Command16_Click:
Exit Sub
'Err_Command16_Click:
MsgBox Err.Description
Resume Exit_Command16_Click
End Sub