Hide Label and Text Box based off Combobox criteria

Robby19

Board Regular
Joined
Mar 19, 2018
Messages
227
I am trying to hide a label and text box if a combo box, within the same form, is blank or "No."

Code:
Private Sub Form_Current() If Not Me.NewRecord Then
  If IsNull(Me!comCFTWaiver) Then
   Me!txtCFTWaiverAppr.Visible = False
   Me!Label81.Visible = False
  Else
   Me!txtCFTWaiverAppr.Visible = True
   Me!Label81.Visible = True
  End If
 Else
  Me!txtCFTWaiverAppr.Visible = True
  Me!Label81.Visible = True
 End If
 End Sub

Can you provide assistance. Using Access 2013.
 
Last edited:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try this syntax

Code:
If Me.comCFTWaiver.Value = "" Then
    Me.txtCFTWaiverAppr.Visible = False
    Me.Label81.Visible = False
Else
    Me.txtCFTWaiverAppr.Visible = True
    Me.Label81.Visible = True
End If
 
Upvote 0
I tested my code (in Access)
Perhaps if you follow the exact same steps to get it to work and then modify to suit your own requirements

1. create a new user form
(mine was auto-named UserForm1)

2. add combobox and rename it comCFTWaiver

3. add textbox and rename it txtCFTWaiverAppr

4. add label and rename it Label81

5. add command button

6. add the code below in UserForm code window

7. test it - clicking the command button toggles textbox & label visibility

Code:
Private Sub [COLOR=#000080]comCFTWaiver[/COLOR]_Change()
If Me.[COLOR=#000080]comCFTWaiver[/COLOR].Value = "" Then
    Me.[COLOR=#4b0082]txtCFTWaiverAppr[/COLOR].Visible = False
    Me.[COLOR=#008000]Label81[/COLOR].Visible = False
Else
    Me.[COLOR=#4b0082]txtCFTWaiverAppr[/COLOR].Visible = True
    Me.[COLOR=#008000]Label81[/COLOR].Visible = True
End If
End Sub

Private Sub CommandButton1_Click()
If Me.[COLOR=#000080]comCFTWaiver[/COLOR] = "" Then Me.[COLOR=#000080]comCFTWaiver [/COLOR]= "XXX" Else Me.[COLOR=#000080]comCFTWaiver[/COLOR] = ""
End Sub

Private Sub UserForm_Initialize()
    Me.txtCFTWaiverAppr.Visible = False
    Me.Label81.Visible = False
End Sub
 
Last edited:
Upvote 0
Try
Code:
If Not Me.NewRecord Then
    Me.txtCFTWaiverAppr.Visible = NOT Nz(Me.comCFTWaiver,"No")="No"
    Me.Label81.Visible = NOT Nz(Me.comCFTWaiver,"No")="No"
End If

HTH
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top