INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to

How and why to code Access Reports by munger
Posted: 7 Nov 02

I live in a non-English speaking country and my workplace has technicions that speak English and managers that speak the local language.  So when I program in Access I always have to fix the reports so the managers will understand.  Access reports, even though they appear like FORMS in DESIGN view, they are quite different.

Even you English-folks out there could have good reason to use codes in Access reports.  One example:

You use a form with a check box whose field is "Breakable".  That field in the underlying table is a yes/no field.  If you use the report wizard to make a report out of that form and you want to group on the "Breakable", so the report is divided into Breakable YES and Breakable NO.  Wouldn't it be better to have "Fragile" and "NonFragile" appear in your report? How do you do that? By code. Where does the code need to be?  Do a right-click on the "DETAIL" section of the report>click "BUILD">click "CODE". Take my advise: DO NOT CODE ANYWHERE ELSE when fiddling with reports.

There is something unusual about coding reports: You can not mention fields in the code that do not have a textbox or check box in the DETAILS section. Don't ask me why.  So if you need a field, place a text box bound to that field in the DETAILS secttion and make it small and invisible. Now your code will work.

Now back to our example ("Breakable Yes"="Fragile"):

Put an unbound textbox in the DETAIL section and call it txtFragile

Code like this:
if [Breakable]=true then
txtFragile="FRAGILE"
else
txtFragile="NON-FRAGILE"    
end if

Now make the checkbox invisible.  Do not delete it or your code will not work!

Of course, fiddle with the unbound textbox to place it properly on the report.

Good Luck.

munger@netvision.net.il

Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close