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

Swap visible text boxes based on field value

Status
Not open for further replies.

CJTyo

Programmer
Sep 17, 2002
181
US
In the detail section of my Report I have one little field which needs to EITHER display a number OR a letter depending on whether it is a form or not. I have managed to figure out how to have JUST the form letter display OR the revision number - but not how to have each line item display whichever is correct.

Procedures have a revision number (ProcRev#).

Forms ALSO have a revision number (ProcRev#), AND a form letter (ProcFormRevLetter) in its own field.

So I check to see if the Letter field is Null, if Yes then I want the Letter field Hidden and the Rev# field Visible - if the Letter field is Not Null then I want the Letter field Visible and the Rev# field Hidden...

This code works to a limited degree - right now, because there ARE Letters, it ONLY displays Letters and no numbers at all:

Private Sub GroupHeader2_Format(Cancel As Integer, FormatCount As Integer)
If Me![ProcFormRevLetter] = Null Then
Me![ProcFormRevLetter].Visible = False
Me![ProcRev#].Visible = True
Else
Me![ProcFormRevLetter].Visible = True
Me![ProcRev#].Visible = False
End If
End Sub

I understand WHY it's hiding the revision numbers - it's acting on the report sort of as a single entity instead of treating each line item (there will almost always be more than one) as a seperate entity.

So what I need to know is how to make the code check each line item instead of it being so "all or nothing." I've tried messing with a For Each, Next statement but end up with the same "all or nothing" situation.

I'm still too new at programming to understand what I really need to have the code checking against...

Help?!

Thanks!


*~*~*~*~*~*~*~*~*~*~*~*~*
Insanity is a matter of Perception. [yinyang]
 
Did you try putting your code in the On Format event of the Detail section??
 
CosmoKramer,

Yep. Does exactly the same thing. I've swapped the code back and forth between the Detail and Group On Format, even tried the On Open - it didn't like that.

:-(

*~*~*~*~*~*~*~*~*~*~*~*~*
Insanity is a matter of Perception. [yinyang]
 
I've found a way to work around it, but I'm not sure if this is proper programming or just cheating because it happens to work!

I put in this code:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me!ProcFormRevLetter = Null Then
Me!ProcFormRevLetter.Visible = False
Else
Me!ProcFormRevLetter.Visible = True
End If
End Sub

And I overlap the Rev# with the Letter on top and the Letter is set to Visible=No in the properties. I was afraid the Rev# would print out underneath the Letter and it would look garbled, but the Rev# doesn't show at all so it does work - though if I move the Letter OFF the Rev# I can see the Rev# is definitely showing.

Not sure why it doesn't "overstrike," and I haven't printed it out yet to see what that looks like, but it looks okay on screen.

<shrug>

C

*~*~*~*~*~*~*~*~*~*~*~*~*
Insanity is a matter of Perception. [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top