Visible Function In Report Header OnFormat Event

J

JK

Any idea why this won't work?

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)

If (IsNull(Me.txtSalesperson) Or Me.txtSalesperson = "") Then
Me.txtSalesperson.Visible = False
Me.txtName.Visible = True
Else
Me.txtSalesperson.Visible = True
Me.txtName.Visible = False
End If
End Sub
 
J

Jeff Boyce

What do you mean by "won't work"? That's not a lot to base remote
diagnostics on...

(can you confirm that you actually have data to check at the Format event?
you could put a breakpoint in and check the values of those controls.)

If you are referring to controls you've added to the report (e.g.,
[txtSalesperson], [txtName]), try using the "!" instead of the ".":

Me!txtSalesperson

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

JK

In my report, I have a field for the salesperson name. The salesperson name
field in my tblCompanies table looks like this "Jim Ahearn
S" so I linked my tblContacts table to the companies table by employee
number and i'm generating the salesperson name using the contacts table,
Salesperson : [FirstName" & " " & [LastName].

The trouble is, I have some Salesperson entries in my companies table that
do not exist in my contacts table, example : "Customer Service (CSR 02 MG) "
So when my report runs, if the customer has "Customer Service (CSR 02 MG) "
listed as the salesperson, txtSalesperson is blank or null or whatever.

So I want the report to display the actual text box bound to the
salesperson name field in my companies table if txtSalesperson is null or
blank otherwise, I want to display txtSalesperson which again, is the field
based on my contacts table.

Hope that all made sense - thx for your help!




Jeff Boyce said:
What do you mean by "won't work"? That's not a lot to base remote
diagnostics on...

(can you confirm that you actually have data to check at the Format event?
you could put a breakpoint in and check the values of those controls.)

If you are referring to controls you've added to the report (e.g.,
[txtSalesperson], [txtName]), try using the "!" instead of the ".":

Me!txtSalesperson

Regards

Jeff Boyce
Microsoft Office/Access MVP


JK said:
Any idea why this won't work?

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)

If (IsNull(Me.txtSalesperson) Or Me.txtSalesperson = "") Then
Me.txtSalesperson.Visible = False
Me.txtName.Visible = True
Else
Me.txtSalesperson.Visible = True
Me.txtName.Visible = False
End If
End Sub
 
J

Jeff Boyce

Try using an IIF() statement to "calculate" what you want to show.

Regards

Jeff Boyce
Microsoft Office/Access MVP

JK said:
In my report, I have a field for the salesperson name. The salesperson
name
field in my tblCompanies table looks like this "Jim Ahearn
S" so I linked my tblContacts table to the companies table by employee
number and i'm generating the salesperson name using the contacts table,
Salesperson : [FirstName" & " " & [LastName].

The trouble is, I have some Salesperson entries in my companies table that
do not exist in my contacts table, example : "Customer Service (CSR 02 MG)
"
So when my report runs, if the customer has "Customer Service (CSR 02 MG)
"
listed as the salesperson, txtSalesperson is blank or null or whatever.

So I want the report to display the actual text box bound to the
salesperson name field in my companies table if txtSalesperson is null or
blank otherwise, I want to display txtSalesperson which again, is the
field
based on my contacts table.

Hope that all made sense - thx for your help!




Jeff Boyce said:
What do you mean by "won't work"? That's not a lot to base remote
diagnostics on...

(can you confirm that you actually have data to check at the Format
event?
you could put a breakpoint in and check the values of those controls.)

If you are referring to controls you've added to the report (e.g.,
[txtSalesperson], [txtName]), try using the "!" instead of the ".":

Me!txtSalesperson

Regards

Jeff Boyce
Microsoft Office/Access MVP


JK said:
Any idea why this won't work?

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As
Integer)

If (IsNull(Me.txtSalesperson) Or Me.txtSalesperson = "") Then
Me.txtSalesperson.Visible = False
Me.txtName.Visible = True
Else
Me.txtSalesperson.Visible = True
Me.txtName.Visible = False
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top