Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Data

Status
Not open for further replies.

ckugo

IS-IT--Management
Jan 6, 2004
165
US
I am trying to print a report that is pulling data from my database. My database consists various employee info. Some employees want certain info not available to others so I created a Yes/No column in my database and have it checked if that want everyone to see their info and no if they don't.

My form works fine with this code:

If Me.chkShowInfo.Value = False Then
Me.Address.Visible = False
Me.City.Visible = False
Me.State.Visible = False
Me.Zip.Visible = False
Me.HomePhone.Visible = False
Me.CellPhone.Visible = False
Me.Birthday.Visible = False
end if

When I try and print the report it is not pulling this over. I have tried putting this code in the report with multiple functions and I haven't had any luck. Does anyone have any advice on this matter?? Any help is greatly apprecited.

Thanks in advance,

Chris
 
Chris,

Where are you putting this code in the report?

The Me property will work for either a form or a report.

If Me.chkShowInfo.Value = False Then
Me.Address.Visible = False
Me.City.Visible = False
Me.State.Visible = False
Me.Zip.Visible = False
Me.HomePhone.Visible = False
Me.CellPhone.Visible = False
Me.Birthday.Visible = False
end if



 
In Private Sub Report_Activate()

When I put it in the report _activate function my condition does not work. It makes all the info for everyone not visible. Thanks,

Chris
 
Chris,

Is Me.chkShowInfo bound to a yes/no field in your table? If so, then you can use an immediate if statement (IIf) in the control source of each field that you want to hide. Assuming that the yes/no field is named [ShowInfo], code such as this will display a null instead of data. Put this in the control source for each text box you want to hide data for.

ControlSource: =IIf([ShowInfo]=False,Null,[Address])

This means that if the field [ShowInfo] is set to false (as it is if a checkbox is dechecked) a null will be displayed. If the field is set to true, the address will be displayed.

Note: If chkShowInfo is bound to a yes/no field, you might have to change "False" in the statement above to "No". Don't use quotes though.

Try that, and let me know.

-Patrick

Nine times out of ten, the simplest solution is the best one.
 
Think you're code is (nearly) OK.

Only two things:
1 - I think I would have placed it in the on format event of the section in which the controls reside
2 - what about also provide an option for visible = true

- this code will toggle the values of the visible properties.

[tt]dim bVisible as Boolean
bVisible = Me!chkShowInfo.Value

Me!Address.Visible = bVisible
Me!City.Visible = bVisible
Me!State.Visible = bVisible
Me!Zip.Visible = bVisible
Me!HomePhone.Visible = bVisible
Me!CellPhone.Visible = bVisible
Me!Birthday.Visible = bVisible[/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top