Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

QueryDef - Defeated/Deflated

$
0
0
Hello,

I have searched for the last few days pretty much everywhere and have made attempt after attempt to code, only to erase code, code, erase code, etc. After about 3 days, I feel defeated, deflated, and just very frustrated.

I am trying to utilize one form. I have multiple queries already configured for this form. The additional queries are simply based on a user's Division and a report of a user requirement for training; 30 days out, 60 days out, 90 days out, and greater than 90 days but less than 120 days.

I know that I am unable to change the recordsource for my report after it has loaded and that the change would need to take place in the report's open event (using QueryDef seems what would be the best option best on my research; unsure).

I have a form (frmGpReports) with a combobox (ComboReport) and a command button (cmdSubmit). After a selection has been made and the command button (cmdSubmit) has been pressed. I open up the report (rptGroupReports) using the following command:

Code:

DoCmd.OpenReport "rptGroupReports", acViewPreview
I am trying to open up the report based on whether the combo box from the other form says; "Within 60 Days" or "Within 90 Days", etc. On the Reports (rptGroupReports) open event I have the following. NOTE: I have literally torn the code out so many times that I cannot count. strReportHeader is an OpenArgs that passes a report title from the other form.

Code:

Dim db As DAO.Database
    Dim qdf As DAO.QueryDef
    Dim strSQL As String
    Set db = CurrentDb
    Set qdf = db.QueryDefs("qryGpAllDue")
    qdf.SQL = "SELECT * FROM tblEmployees;"
    'strSQL = "SELECT * FROM Employees WHERE ([dtClassRecertification]='Between Now() And Now()+90')"
   
    DoCmd.OpenReport "rptGroupDue", acViewReport, strSQL, , , strReportHeader

Any help would be greatly appreciated. Signed, Frustrated, but determined

Viewing all articles
Browse latest Browse all 13329

Trending Articles