check box & code

geoffreyp

Registered User.
Local time
Tomorrow, 00:58
Joined
Nov 27, 2009
Messages
13
I am creating an art exhibition catalogue. I have a form which i have a check box[ContactDetails] for showing/not an artists contact details. I have tried the following code in the "On format" and "On Print" events without any luck.
Anyone able to give me some direction here?:o

Private Sub GroupHeader0_Print(Cancel As Integer, PrintCount As Integer)

If Me.ContactDetails = 0 Then

Me.address.Visible = False
Me.town.Visible = False
Me.Home_phone.Visible = False

Else

Me.address.Visible = True
Me.town.Visible = True
Me.Home_phone.Visible = True

End If

End Sub
 
Is this a form or a report? What version of Access?
 
Try putting your code in between:

Private Sub Form_Current()

End Sub
 
I am creating an art exhibition catalogue. I have a form which i have a check box[ContactDetails] for showing/not an artists contact details. I have tried the following code in the "On format" and "On Print" events without any luck.
Anyone able to give me some direction here?:o

Private Sub GroupHeader0_Print(Cancel As Integer, PrintCount As Integer)

If Me.ContactDetails = 0 Then

Me.address.Visible = False
Me.town.Visible = False
Me.Home_phone.Visible = False

Else

Me.address.Visible = True
Me.town.Visible = True
Me.Home_phone.Visible = True

End If

End Sub


This looks like code for a report. So you basically are trying to open the report from your form correct?

You could open the report in design view, set the enabled property of the controls using the Reports() collection, then reopen the form in Print Preview. That's one way.
 
Sorry for the lack detail here. I am Using access 07 & the code is running in a report to prevent artist address details from being printed in the catalogue if that is what they have selected.
Thanks to all so far

:o
 
Select the Detail (bar) section and put your code in the On Format event. The signature of the code should be something like:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

And remove all the "Me."
 
As you mentioned you've tried the code in the format event (and I agree that's the correct event), I'll point out that the format event does not fire if you open the report in the new "Report" view available in 2007, only in Print or Preview.
 
Thanks Paul, it's been working all the time and I've been driving myself nuts(plus distracting others) trying different things, ah so simple!
Onto the next challenge!
Many thanks!
 
No problem, and welcome to the site by the way!
 
As you mentioned you've tried the code in the format event (and I agree that's the correct event), I'll point out that the format event does not fire if you open the report in the new "Report" view available in 2007, only in Print or Preview.

Paul, do you have any ideas why they changed that?
 
Well, I'm not sure I'd call it a change, since that view didn't exist before, but it is certainly confusing. I ran into this same issue early on, and it drove me crazy (okay, crazier). The new view seems to me like some sort of form/report hybrid, since it is interactive. I imagine that at the core level, they couldn't let the section events fire and still get the other features. In other words, I have no idea. :p
 
I'm almost sure that view was there in 2003, almost but not positive :) Isn't it just the Layout view that's new to 07? I can't even remember myself lol.
 
Haha! Don't worry, I'm not feeling bad. It's good to be educated.

And as you rightly stated, that's the Report view for reports is the equivalent of the Layout view for forms so you can manipulate layout. I can see why the Format event doesn't fire.
 

Users who are viewing this thread

Back
Top Bottom