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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with VBA code for Microsoft Access

Status
Not open for further replies.

mrollz

Programmer
Feb 3, 2006
4
0
0
US
It's been a while since I've had to do coding so I'm quite rusty. However I'm using Microsoft Access to create a report of all the projects and their corresponding data (file paths, descriptions, file names, etc) that I've completed. What I've done is create separate tables for each piece of data. For example, I have a table devoted to what's called "Batch Point Files" for each project. My problem is that while some jobs have over 15 batch point files, some have none. When I run my report, Access reserves a blank line on each page for these files that don't exist for some projects. I would basically like to be able to write a short function that will essentially hide these fields in the report if they are empty. Something like:
If (field(x) = null) Then
field(x).Visible = False
End If
I'm having trouble moving from the above pseudocode to working code that will also hide all the fields after field(x).
Any help you can offer will be very much appreciated. If I've been unclear about what I need, I can and will provide more information. Thank you.
Regards,
Matthew Rowles
Town of Chapel Hill
Engineering
 
On the OnFormat event of the Details section you could use
Code:
field(x).Properties("Visible") = IsNull(field(x))

-Pete
 
My guess is that you were having problems with
if variable = null then ...
Even if it was null, this evaluated to false. This is a real common problem. See thread702-1183929 for the reason why and other solutions

important Use the IsNull function to determine whether an expression contains a Null value. Expressions that you might expect to evaluate to True under some circumstances, such as If Var = Null and If Var <> Null, are always False. This is because any expression containing a Null is itself Null and, therefore, False.
 
Thanks a lot ya'll, I got the event to work properly. You have been a world of help.
Regards,
Matthew Rowles
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top