I am generating a report in Access from a query. How can I modify the Query from VB?
I am not curently sending and SQL query, i am using one generated in Access. The problem is i want to be able to change the query (or pass a query) at runtime without giving the user direct access to the database. I am currently using:
Code:
Private Sub button_Click()
Dim strDummy As String

On Error Resume Next

strDummy = Printer.DeviceName
   
If Err.Number Then
    MsgBox "There are no printers installed on this computer. Please install a printer and try again.", vbInformation
Else
    RunAccessReport App.Path & "\RecuitmentPlanner.mdb", "Candidates"
End If
End Sub

Public Sub RunAccessReport(strDB As String, strReport As String)
Dim AccessDB As Access.Application

    Set AccessDB = New Access.Application
    AccessDB.OpenCurrentDatabase strDB
    AccessDB.DoCmd.OpenReport strReport, acViewPreview
    AccessDB.Visible = False
    AccessDB.DoCmd.PrintOut (acPrintAll)
    AccessDB.Quit acQuitSaveAll
    Set AccessDB = Nothing
    
End Sub
How can i pass a query using this method or is there another way to generate reports?