Have a Report with the Parent Report's recordsource set to a table containing company header style info. This populates the Report Header text boxes and labels.
A Sub Report Detail Section has been embedded into the PArent Report's Detail Section.
I am trying to assign the sub report with a secondary Record Source. Is this supported? I am using MS Access 2007.
Currently, struggling with the following code. Have run out of ideas / forums etc at this stage. If supported, I must be overlooking some syntax or other. My SQL skills are suspect I fear.
Any guidance would be much appreciated.
A Sub Report Detail Section has been embedded into the PArent Report's Detail Section.
I am trying to assign the sub report with a secondary Record Source. Is this supported? I am using MS Access 2007.
Currently, struggling with the following code. Have run out of ideas / forums etc at this stage. If supported, I must be overlooking some syntax or other. My SQL skills are suspect I fear.
Code:
Private Sub SetUp()
' Set up the Report's Filter
Dim frm As Form_frmReportCriteria
Dim strSQL As String
Dim strWhere As String
Dim ptOption As Integer
Dim billingOption As Integer
'Set frm = Forms(FRM_CRIT)
'Check for user options to declare sqlString recordsource
ptOption = Forms!frmReportCriteria.optPatients.Value
billingOption = Forms!frmReportCriteria.optGpBilling.Value
Select Case (ptOption)
'This patient Case
Case Is = 1
Select Case (billingOption)
'selected patient receipt
Case Is = 1
strWhere = "WHERE ((([tblbillingrates.billingrateamount]*[hours])>0) AND ((tblappointments.appointmentdate) Between [Forms!frmReportCriteria.txtBeginDate] And [Forms!frmReportCriteria.txtEndDate]) AND ((tblappointments.paid)=True)) AND ((tblpatients.patientID) = Forms!frmpatientsappts.patientID)"
Case Is = 2
'selected patient invoice
strWhere = "WHERE ((([tblbillingrates.billingrateamount]*[hours])>0) AND ((tblappointments.appointmentdate) Between [Forms!frmReportCriteria.txtBeginDate] And [Forms!frmReportCriteria.txtEndDate]) AND ((tblappointments.paid)=False)) AND ((tblpatients.patientID) = Forms!frmpatientsappts.patientID)"
'selected patient statement
Case Is = 3
strWhere = "WHERE ((([tblbillingrates.billingrateamount]*[hours])>0) AND ((tblappointments.appointmentdate)<Now()) AND ((tblappointments.paid)=False)) AND ((tblpatients.patientID) = Forms!frmpatientsappts.patientID)"
End Select
'All Patients Case
Case Is = 2
Select Case (billingOption)
'selected patients receipt
Case Is = 1
strWhere = "WHERE((([tblbillingrates.billingrateamount]*[hours])>0) AND ((tblappointments.appointmentdate) Between [Forms!frmReportCriteria.txtBeginDate] And [Forms!frmReportCriteria.txtEndDate]) AND ((tblappointments.paid)=True))"
'selected patients invoice
Case Is = 2
strWhere = "WHERE((([tblbillingrates.billingrateamount]*[hours])>0) AND ((tblappointments.appointmentdate) Between [Forms!frmReportCriteria.txtBeginDate] And [Forms!frmReportCriteria.txtEndDate]) AND ((tblappointments.paid)=False))"
'selected patients statement
Case Is = 3
strWhere = "WHERE((([tblbillingrates.billingrateamount]*[hours])>0) AND ((tblappointments.appointmentdate)<Now()) AND ((tblappointments.paid)=False))"
End Select
End Select
'Sub Report RecordSource with "strWhere" parameter
strSQL = "SELECT tblpatients.insurerID, tblpatients.patientID, [billingrateamount]*[hours] AS " & _
"InvoiceAmount, tblappointmentduration.hours, tblpatients.dob, tblpatients.pttitle, " & _
"tblpatients.firstname, tblpatients.lastname, tblpatients.insref, tblpatients.active, " & _
"tblbillingrates.billingrateText, tblinsurers.providerno, tblbillingrates.billingrateamount, " & _
"tblappointments.appointmenttimestart, tblappointments.appointmentdate, " & _
"tblappointments.paid, CCur(Charging([tblpatients.distance],[InvoiceAmount],[tblbillingrates.billingrateID],[physioID])) AS " & _
"Expr1, tblappointments.physioID, tblappointments.baddebt, tblappointments.appointmentID, " & _
" tblinsurers.insurerID, tblinsurers.insurerName, tblpatients.distance, tblpatients.address1, " & _
"tblpatients.address2, tblpatients.town, tblpatients.county, tblpatients.country, " & _
"tblpatients.postcode, tblpatients.tel, tblpatients.mobile, tblpatients.distance, " & _
"tblbillingrates.billingrateID, tblpractices.practiceID, tblpractices.practiceName, " & _
"tblinsurers.contactTitle, tblinsurers.contactname, tblinsurers.address1, " & _
"tblinsurers.address2, tblinsurers.town, tblinsurers.county, tblinsurers.postcode " & _
"FROM tblbillingrates INNER JOIN (tblpractices INNER JOIN " & _
" ((tblinsurers INNER JOIN tblpatients ON tblinsurers.insurerID=tblpatients.insurerID) " & _
"INNER JOIN (tblappointmentduration INNER JOIN tblappointments ON " & _
"tblappointmentduration.apptdurationID=tblappointments.apptdurationID) ON " & _
"tblpatients.patientID=tblappointments.patientID) ON tblpractices.practiceID=tblpatients.practiceID) ON " & _
"tblbillingrates.billingrateID=tblappointments.billingrateID & strWhere"
'Apply the strWhere Parameter?????
'& strWhere;"
'Assign approprate strSQL as the Sub Report RecordSource, debug to finish
Reports!rptNoCriteriaBilling!rptdipmabilling.Report.RecordSource = strSQL
Debug.Print strSQL
'Success
Debug.Print strWhere
'Success
End Sub
Any guidance would be much appreciated.