Solved Help with recordset (1 Viewer)

bwc

Registered User.
Local time
Today, 15:08
Joined
Feb 7, 2013
Messages
34
The Debug.Print shows the results I want to see. Lots of True and False
Code:
Public Function chkQry()
    Dim rs As Recordset
    Set rs = CurrentDb.OpenRecordset("SELECT * FROM reportQ")
        While Not rs.EOF
            Debug.Print rs!Clinician = " & openRptCbo & " And rs!dateEntered = TempVars("enterDate").Value And rs!isPaid = True
            rs.MoveNext
        Wend
    rs.Close
    Set rs = Nothing
End Function
How do I send it to a OnClick event to filter a report? The report is bound to the query in the recordset
Code:
Private Sub indPaidRptBtn_Click()
    DoCmd.OpenReport "pbR", acViewReport, , chkQry = True
End Sub
Rather then the getting a filtered report, I get a blank report
 
Solution
You could try something like:
Code:
Private Sub indPaidRptBtn_Click()
OpenMyReport True
End Sub

Private Sub indUnPaidRptBtn_Click()
OpenMyReport False
End Sub

Private Sub OpenMyReport(Paid As Boolean)
DoCmd.OpenReport "pbR", acViewReport, , "Clinician=""" & openRptCbo & """ and [isPaid]=" & Paid & " and [dateEntered]=#" & TempVars("enterDate").Value & "#"
End Sub

(untested)
Sent from phone...
the function chkQry() doesn't do/return anything.
try this:
Code:
Private Sub indPaidRptBtn_Click()
    DoCmd.OpenReport "pbR", acViewReport, , chkQry = True
DoCmd.OpenReport ReportName:="pbR", View:=acViewReport, _
     WhereCondition:="Clinician = " & openRptCbo & " And " & _
      "dateEntered = #" & Format$(TempVars("enterDate").Value, "mm/dd/yyyy") & "# And isPaid = True"
End Sub
 
the function chkQry() doesn't do/return anything.
try this:
Code:
Private Sub indPaidRptBtn_Click()
    DoCmd.OpenReport "pbR", acViewReport, , chkQry = True
DoCmd.OpenReport ReportName:="pbR", View:=acViewReport, _
     WhereCondition:="Clinician = " & openRptCbo & " And " & _
      "dateEntered = #" & Format$(TempVars("enterDate").Value, "mm/dd/yyyy") & "# And isPaid = True"
End Sub

thank you for your reply. I do have something similar to that. I want to put it in a function because I find myself duplicating code...

Code:
Private Sub indPaidRptBtn_Click()
    DoCmd.OpenReport "pbR", acViewReport, , _
        "Clinician=""" & openRptCbo & """ and [isPaid]= True and [dateEntered]=#" & TempVars("enterDate").Value & "#"
End Sub

Private Sub indUnPaidRptBtn_Click()
    DoCmd.OpenReport "pbR", acViewReport, , _
        "Clinician=""" & openRptCbo & """ and [isPaid]= False and [dateEntered]=#" & TempVars("enterDate").Value & "#"
End Sub
 
You could try something like:
Code:
Private Sub indPaidRptBtn_Click()
OpenMyReport True
End Sub

Private Sub indUnPaidRptBtn_Click()
OpenMyReport False
End Sub

Private Sub OpenMyReport(Paid As Boolean)
DoCmd.OpenReport "pbR", acViewReport, , "Clinician=""" & openRptCbo & """ and [isPaid]=" & Paid & " and [dateEntered]=#" & TempVars("enterDate").Value & "#"
End Sub

(untested)
Sent from phone...
 
Solution
You could try something like:
Code:
Private Sub indPaidRptBtn_Click()
OpenMyReport True
End Sub

Private Sub indUnPaidRptBtn_Click()
OpenMyReport False
End Sub

Private Sub OpenMyReport(Paid As Boolean)
DoCmd.OpenReport "pbR", acViewReport, , "Clinician=""" & openRptCbo & """ and [isPaid]=" & Paid & " and [dateEntered]=#" & TempVars("enterDate").Value & "#"
End Sub

(untested)
Sent from phone...

Thank you. That worked
 

Users who are viewing this thread

Back
Top Bottom