ChewDinCompSci
Technical User
I have a form that allows the user to select a specific date (cboRptDate) and equipment number (cboRptEquip) out of a large amount of records and then create a report on those choices. The report works fine however I want the user to have the option of also choosing all trucks (equipment) that were used on a specific date chosen. The code I have tried is on the RowSource for the equipment combobox is...
SELECT [LKP_tblEquipmentNumbers].[Equipment Number] FROM LKP_tblEquipmentNumbers, UNION SELECT "0" As AllChoice From LKP_tblEquipmentNumbers;
Also, just to provide a little more info about how this form works, the code for the command button to create the report:
Private Sub cmdmakereport_Click()
If IsNull([cboRptDate]) Or IsNull([cboRptEquip]) Then
MsgBox "You must enter both a date and equipment number."
DoCmd.GoToControl "cboRptDate"
Else
Dim sql_DateRpt, sqltv, sqlfv As String
Dim rsDateRpt As Recordset
Dim rsTV As Recordset
'Disable all warning messages for changes made by action query
DoCmd.SetWarnings False
CurrentDb.Execute "Drop table tblrpt_RouteLog"
DoCmd.OpenQuery "qry_MakeRouteTable"
sqltv = "Select * from tblrpt_RouteLog"
Set rsTV = CurrentDb.OpenRecordset(sqltv, dbOpenDynaset)
If rsTV.RecordCount = 0 Then
MsgBox "There is no data for this report. Canceling report..."
rsTV.Close
Set rsTV = Nothing
Else
DoCmd.OpenReport "rpt_qryByTruck", acViewPreview
End If
End If
End Sub
When I choose "0" and click the cmd I get the "There is no data..." msgbox. Any ideas???
MatChew
codename: vba4dumbE
SELECT [LKP_tblEquipmentNumbers].[Equipment Number] FROM LKP_tblEquipmentNumbers, UNION SELECT "0" As AllChoice From LKP_tblEquipmentNumbers;
Also, just to provide a little more info about how this form works, the code for the command button to create the report:
Private Sub cmdmakereport_Click()
If IsNull([cboRptDate]) Or IsNull([cboRptEquip]) Then
MsgBox "You must enter both a date and equipment number."
DoCmd.GoToControl "cboRptDate"
Else
Dim sql_DateRpt, sqltv, sqlfv As String
Dim rsDateRpt As Recordset
Dim rsTV As Recordset
'Disable all warning messages for changes made by action query
DoCmd.SetWarnings False
CurrentDb.Execute "Drop table tblrpt_RouteLog"
DoCmd.OpenQuery "qry_MakeRouteTable"
sqltv = "Select * from tblrpt_RouteLog"
Set rsTV = CurrentDb.OpenRecordset(sqltv, dbOpenDynaset)
If rsTV.RecordCount = 0 Then
MsgBox "There is no data for this report. Canceling report..."
rsTV.Close
Set rsTV = Nothing
Else
DoCmd.OpenReport "rpt_qryByTruck", acViewPreview
End If
End If
End Sub
When I choose "0" and click the cmd I get the "There is no data..." msgbox. Any ideas???
MatChew
codename: vba4dumbE