Conditionally Show Textbox

  • Thread starter Thread starter Cassandra
  • Start date Start date
C

Cassandra

On my invoice I show payment type 1, 2 or 3. How do I set up a textbox on the
report so it is visible when payment type is 1 and not visible when payment type
is 2 or 3?

Thanks!

Cassandra
 
open the report in design view.
click in the section that holds the textbox.
from the Properties box, add a procedure in the section's
On Format event, as

If Me!Textbox = 1 then
Me!Textbox.Visible = True
Else
Me!Textbox.Visible = False
End If

didn't test above, but should work.
hth
 
Use the After Update event procedure of PaymentType to set the Visible
property of the text box:

Private Sub PaymentType_AfterUpdate()
Dim bShow As Boolean
If Me.[PaymentType] = 1 Then
bShow = True
Else
bShow = False
End If
If Me.[NameOfYourTextBox].Visible <> bShow Then
Me.[NameOfYourTextBox].Visible = bShow
End If
End Sub

You also need to run this code when a record loads into the form, i.e. in
the Current even of the form:
Private Sub Form_Current()
Call Sub PaymentType_AfterUpdate
End Sub

You may also want to do something similar in the Undo event of the form,
using the OldValue of PaymentType.
 
Sorry: missed that. Fredg posted the right answer.

You could use the code I suggested in the Format event of the Detail section
of the report. It is safer (handles possible Null values) and slightly more
efficient (doesn't change the Visible property unless it needs changing).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to the newsgroup. (Email address has spurious "_SpamTrap")

Cassandra said:
Allen,

Thanks for responding! My question is about a textbox on a report!

Cassandra

Allen Browne said:
Use the After Update event procedure of PaymentType to set the Visible
property of the text box:

Private Sub PaymentType_AfterUpdate()
Dim bShow As Boolean
If Me.[PaymentType] = 1 Then
bShow = True
Else
bShow = False
End If
If Me.[NameOfYourTextBox].Visible <> bShow Then
Me.[NameOfYourTextBox].Visible = bShow
End If
End Sub

You also need to run this code when a record loads into the form, i.e. in
the Current even of the form:
Private Sub Form_Current()
Call Sub PaymentType_AfterUpdate
End Sub

You may also want to do something similar in the Undo event of the form,
using the OldValue of PaymentType.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to the newsgroup. (Email address has spurious "_SpamTrap")

Cassandra said:
On my invoice I show payment type 1, 2 or 3. How do I set up a textbox
on
the
report so it is visible when payment type is 1 and not visible when payment type
is 2 or 3?

Thanks!

Cassandra
 
Back
Top