Last week I asked for some help on coding a form to allow the user to choose a specific date and equipment number to retrieve specific data from numerous records and then send that data to a report. Thank you for all the help. I used the following code on my "report generator" form:
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
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
An action query makes a table on the queried data that data is called on by another table ("tblrpt_RouteLog") which is the RecordSource for the report. This table is first dropped and other data goes in each time a new report is made. The following SQL is necessary on the action query "qry_MakeRouteTable":
SELECT [tblRouteLog Query].* INTO tblrpt_RouteLog
FROM [tblRouteLog Query];
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.