Populate an unbound check box on a report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

In summary, I have some code that populates an unbound check box on a form
(thanks to the help of Rick Brandt and fredg). Now I want the same
functionality on a report, but I cant seem to make it work. Any help would
be appreciated.

I call the report from the form with all the required data on it using the
following code

'***** printing code starts here *******
Dim strReportName As String
Dim strCriteria As String

'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If

If NewRecord Then
MsgBox "This record contains no data." _
, vbInformation, "Invalid Action"
Exit Sub
Else
strReportName = "rpt01CompanyDetails"
strCriteria = "[CoID]= " & Me![CoID]

DoCmd.OpenReport strReportName, acViewPreview, , strCriteria

End If

' ***** printing code ends here *******


I have the following code in the on_current event of a form that checks or
unchecks a check box given the test criteria. I want to be able to do the
same thing but so that the unbound check boxes are populated on the report.

'********** code starts here*************

If (Now() >= #7/1/2001# And Forms!frm02Company.LicenceGranted _
<= #6/30/2002# And IsNull(Forms!frm02Company.LicenceSurrendered)) _
Or (Now() >= #7/1/2001# And Forms!frm02Company.LicenceGranted _
<= #6/30/2002# And Forms!frm02Company.LicenceSurrendered _
= #7/1/2001#) Then
Forms!frm02Company.chk2001_02.Value = True
Else
Forms!frm02Company.chk2001_02.Value = False
End If

'********** code ends here**************

I have changed the "Forms!frm02Company" reference to "Me" in the report but
that was not successful. Can I reference the report fields somehow (for
example something like reports!rpt02CustomerDeatils.LicenceGranted <=
#6/30/2002#) and apply the same test and popluate an unbound check box on a
report?

Many thanks for any assistance.
 
Dylan,

You must put your code in the Format event of the relevant report
section (Detail?). The Me. keyword will work just fine for referencing
the report controls, as long as the code is in the report's own module
(which is the case anyway if you put it in a report event like Detail
Format).

HTH,
Nikos
 
Back
Top