VBA in a report

MartijnAn

Registered User.
Local time
Today, 13:56
Joined
Sep 30, 2004
Messages
51
Hi All,

I found out that it is hard to write code for a report. What I want to do is the following:

I want a report that is exactly the same as the results showing on a form. Because a Form is not for printing I use a report. On the form I have a checklist wich depends whatever the value of the 'sourcefield' is. I used this code:

Private Sub Checklist1_BeforeUpdate(Cancel As Integer)
If [att].Value = True Then
Checklist1.Value = True
End If
End Sub

Now why can't I use this same code for a report?
 
This code actually modifies the value of a field (and looks like it should generate an error in any event). There is no need to replicate it in a report.

Report controls do not have events so there is no place to put code at the control level. You can put formatting code in the appropriate section's Format event.

If you add a print button to your form, make sure to add a line of code in the click event to force the current record to be saved before opening the report.

DoCmd.RunCommand acCmdSaveRecord
 

Users who are viewing this thread

Back
Top Bottom