I am stuck. I am trying to create a public function that will print a report so that i can call the report from different forms. i have this code that opens rptFlu (bound to qryClinicData - query is not filtered);
and frmCheckIn (unbound) writes the data to the table;
and then prints rptFlu. the problem i am having is that it prints all the records, so i put
to filter the report, but now i get a "variable not defined" error
clstrPHA,clstrHIV,clstrOver40lab,clstrFlu,clstrHep,clstrTdap, clstrProfileReview are yes/no fields in table and check boxs on form
Code:
Option Compare Database
Option Explicit
Function printFlu()
DoCmd.OpenReport "rptFlu", acViewNormal, , "clstrFlu = True Or clstrHep = True Or clstrTdap = True"
End Function
Code:
Option Compare Database
Option Explicit
Public Function checkIn()
Dim db As DAO.Database
Set db = CurrentDb()
db.Execute " INSERT INTO tblClinicData " _
& "(clstrNameInd,clstrSSN,clstrLocation,cldatTimeIn,cldatDate,clstrPHA,clstrHIV,clstrOver40lab, " _
& "clstrFlu,clstrHep,clstrTdap, clstrProfileReview,clstrRemarks,clstrCell)" _
& " VALUES " _
& "('" & Forms!frmCheckIn.cboSoldierName.Column(0) & "', '" & Forms!frmCheckIn.cboSoldierName.Column(1) & "', " _
& "'" & Forms!frmCheckIn.txtclstrLocation & "', '" & Time() & "','" & Date & "','" & Forms!frmCheckIn.ckclstrPHA & "'," _
& "'" & Forms!frmCheckIn.ckclstrHIV & "','" & Forms!frmCheckIn.ckclstrOver40lab & "', '" & Forms!frmCheckIn.ckclstrFlu & "'," _
& "'" & Forms!frmCheckIn.ckclstrHep & "','" & Forms!frmCheckIn.ckclstrTdap & "','" & Forms!frmCheckIn.ckclstrProfileReview & " '," _
& "'" & Forms!frmCheckIn.txtclstrRemarks & "','" & Forms!frmCheckIn.txtclstrCell & "');"
' db.Close
If Forms!frmCheckIn.ckclstrFlu = True [COLOR=red]And tblClinicData!clstrNameInd = Forms!frmCheckIn.cboSoldierName.Column(0)[/COLOR] Then Call printFlu
End Function
Code:
...And tblClinicData!clstrNameInd = Forms!frmCheckIn.cboSoldierName.Column(0)...
clstrPHA,clstrHIV,clstrOver40lab,clstrFlu,clstrHep,clstrTdap, clstrProfileReview are yes/no fields in table and check boxs on form