INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to

Code a form with combo boxes to report queried data by ChewDinCompSci
Posted: 4 Jan 05

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
        
        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

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];


I hope this is of some help to someone.

MatChew

Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close