controls on a report (1 Viewer)

RpbertS

Registered User.
Local time
Today, 13:20
Joined
Feb 14, 2000
Messages
93
Hi I have a quick question you guys/gals maybe will be able to answer. how the heck does vba handle controls ? My probelm:

I have a report that when a certain condition is met I want certain controls to not be visible when printed.

---------code----
If Subprojects.Value = "" Then
GroupHeader1.Visible = False
End If
--------code-----
pretty simple, I expected the whole header and the controls in it to be invisible when the condition was met, except only the first control in the header is affected, I can't seem to refer to the controls individually either I tried it on the 3 different events also, any ideas ?

this problem is plaguing two people right now in the reports forum any help would be very much appreciated

thanks for the time,
Rpb

[This message has been edited by RpbertS (edited 05-22-2000).]
 

bobjames

Registered User.
Local time
Today, 13:20
Joined
May 8, 2000
Messages
23
Your code needs to be in the OnFormat event for that header and your "if" statement isn’t correct. You need to turn the Visible property on AND off, using the Else


If Subprojects.Value = "" Then
GroupHeader1.Visible = False
Else
GroupHeader1.Visible = True
End If
 

RpbertS

Registered User.
Local time
Today, 13:20
Joined
Feb 14, 2000
Messages
93
unfortunatly that does not work, it still only changes the first control. how do you get in there and change the properties of each control? you cannot do it the normal way

field1.visible=false or whatever

if anyone needs more clarification on the problem just let me know

thanks again,
Rpb

thanks for the reply bobjames..just remembered my tennis coach when I was young was bobjames, thats not you is it ? probaly not

[This message has been edited by RpbertS (edited 05-22-2000).]
 

bobjames

Registered User.
Local time
Today, 13:20
Joined
May 8, 2000
Messages
23
Are all the controls you want to hide in the same group header? from what event are you executing your code?

I'm confused cause the code I posted should work if put in the format event for that group header.
 

RpbertS

Registered User.
Local time
Today, 13:20
Joined
Feb 14, 2000
Messages
93
yup they are all in the subprojects group header. I was originally executing the code from the on print event but then tried the format event upon your reply. I have decent experience in VB and I have no idea why this isn't working in VBA.

thanks again,
Rpb
 

bobjames

Registered User.
Local time
Today, 13:20
Joined
May 8, 2000
Messages
23
Did you try to set the Visible property to false for each control? Are you testing for Null, Empty, and "" [Zero Length]?

Try this:

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

if field1 = "" or isnull(field1)_
or isempty(field1) then

field1.visible = false
field2.visible = false
field3.visible = false

else
field1.visible = true
field2.visible = true
field3.visible = true

end if


End Sub

P.S. Can't play tennis worth a damm. could never find a left handed Racquet.
 

Louise

Registered User.
Local time
Today, 13:20
Joined
Oct 28, 1999
Messages
26
I finally got this to work!
Yes it must be in the OnFormat event rather than OnOpen.
Also I changed the default property on the ole to be non visible.
Then because I couldn't get it to work by checking whether the 4 fields were null, I had it check for the 2 fields that total these 4, but because they were calculated, I had to specify

If Control1 = 0 And Control2 = 0 Then
Me!Signature2.Visible = False
Else:
Me!Signature2.Visible = True
End If

IsNull, IsEmpty, and "" don't work for calculated fields, you have to specify 0 unless your calculation includes a (if formula = 0, "", otherwise formula).

Hope this helps others too.
Thanks to all those who spent time on this, it's very much appreciated!
 

RpbertS

Registered User.
Local time
Today, 13:20
Joined
Feb 14, 2000
Messages
93
thanks bob and louise based on your replies I was able to correct the problem,

it was a huge help and Im glad that problem is over with thanks!

Rpb
 

Users who are viewing this thread

Top Bottom