Suppressing printing of controls when control value is null

dderolph

New member
Local time
Today, 18:20
Joined
Dec 1, 2008
Messages
9
I'm using Access 2007 and working on an assignment for a class on Access. One part of the assignment requires suppressing the printing of three controls based on a certain table when the PaymentID control value is null. The book gives a hint; it says, "Use the Detail section's Format event, and use assignment statements for all the labels and text boxes in the Detail section similar to Me![control name].Visible = True/False, where Me refers to the open form, and True/False means to select the appropriate property setting."

I'm lost. What is the "Detail section's Format event" and what are "assignment statements"? I've gone back to the parts of the textbook searching for the procedure, but haven't stumbled across it yet.

Can someone give me some direction here?
 
Double clicking on the bar that says "Detail" in design view should expose the event for you. Assignment statements are statement like the example given to you:

Me![control name].Visible = True
 
OK, is On Print where I need to enter the statement? I tried putting
Me![PaymentID].Visible = True there but that did not work.
 
Your instructions didn't say Print event:

"Use the Detail section's Format event

Further, you need code to set it both ways; think If/Then/Else.
 
I am tryiing to solve the same issue; modify a report to supress printing when a specific control value is null. The statement below produces a Run-Time Error 424 Object Required messages. Any suggestions?

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Me!PaymentID Is Null Then
Me!PaymentID.Visible = True
Else
Me!PaymentID.Visible = False
End If
End Sub
 
Try the format event that was mentioned previously in the thread, and the IsNull() function.
 
I am using the On Print Event

Also attempted the IsNull (). The statement is below. No error, but doesn't supress either.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If IsNull(Me!PaymentID) Then
Me!PaymentID.Visible = False
Else
Me!PaymentID.Visible = True
End If
End Sub
 
I know what event you're using; that's why I suggested trying the format event. ;)
 
Are you opening the report in preview mode? The format event doesn't fire in Report view.
 
I'm looking to get something like this done as well. Basically I'm looking for a text box to display a value (in this case "Empty) if the underlying query returns no results. I'm also looking at getting the associated labels to disappear. I've looked at Nz statements, IIF statements in the query but for some reason I can not get it to work. I'm :banghead: PLEASE HELP!
 
Did you get this sorted out? I've been out of the country, so have had limited connectivity. I'd use the no data event to handle this, I think.
 

Users who are viewing this thread

Back
Top Bottom