Conditionally Show Textbox

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
 
A

Allen Browne

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.
 
A

Allen Browne

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
 

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