VB code refresh on Print

jguscs

Registered User.
Local time
Yesterday, 22:46
Joined
Jun 23, 2003
Messages
148
Is there any way I can have each record's controls refresh their conditional VB code for each record printed?
Specifically:
I have some simple VB code that conditionally hides a control in the form (depending what's in another control).
It works fluidly when browsing from record to record on-screen; however, when the form's records are printed, the conditional VB code is "skipped" leaving "un-refreshed" controls for each record/page.

I realize that, when it comes to printing, forms are less easily manupilated than reports. However, I can not add the same conditional VB code actions to controls in a report as I can in a form (can I?).

Sample Code:

Private Sub Form_Current()
If Len(Forms![My Form]![FieldA] = 0) Then
Forms![Equipment Profile]![Check100] = True
Else
Forms![My Form]![Check100] = False
End If
 
Try your conditional code in the On Print event of the detail section of your report.

Something like:

If Len(Me![FieldA]) = 0 Then
Me[Check100].Visible = True
Else
Me![Check100].Visible = False
End If


hth,
Jack
 
Right, thanks.
In the mean time, I realized that I really need to do this in a form, not a report, due to the fact that there need to be some modifyable fields for the users.
So...
Is there any way I can have a printed form pay attention to its visual basic code?
 
Again, thanks Pat (conditional formatting does work in the Format event, BTW)...
Only thing is that I need to use a form, not a report.
Any ideas?
 
Pat -

DRAT! And I tried some simple code in the On Print event and it was doing what I wanted... I had originaly said either the On Print or On Format but wanted to be more specific so I did a simple test....

Thank you for pointing out my error!

JGUSCS -

I am not sure what you are doing but it sounds like you can still use a report. Just print a report based on the record the user is working with rather than all the records. I assume that if the user is working with a single record that you only want to print that record as that is all that would be printed if your printed the form. You can refer to the form in the code in your report if you need to.

LOL! Did I get this one right Pat?

Jack
 
Pat -

This is the code that I used in the On Print event and it hid the correct control and showed all others:

If Me.ReqID = 72 Then
Me.RequestDate.Visible = False
Else
Me.RequestDate.Visible = True
End If

What did I miss, IF you have the time....

Jack
 
It seems that the code works in either the Print or the Format
sub procedures.

I've pretty much given up on doing it in forms.
It works in reports, so. There.
 
I am glad you got it sorted and working! Continued success with your project....

With thanks to Pat for peering over my shoulder and keeping me on my toes. Thanks Pat!

Jack
 

Users who are viewing this thread

Back
Top Bottom