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

If/Then stmt for Ckbox AfterUpdate

Status
Not open for further replies.

KerryL

Technical User
May 7, 2001
545
US
One of my forms contains a checkbox signifying that Worker Orientation Mtgs have been scheduled. If a user selects it I'd like a label and 3 txt boxes (whose Visible properties are all set to No) to become visible.

I created this code in the AfterUpdate event of the check box, but the 4 objects are not becoming visible when the check box is selected. What have I done wrong?


<code>

Private Sub ckWOM_AfterUpdate()

If yes Then
Me.lblMtgDates.Visible = True
Me.txtEmplOrMtg1.Visible = True
Me.txtEmplOrMtg2.Visible = True
Me.txtEmplOrMtg3.Visible = True
Else
End If

End Sub

<code>
 
I'm not sure what yes is but you can use this:
Code:
Private Sub ckWOM_AfterUpdate()

    If [red]ckWOM.Value = -1[/red] Then 'you can also use true which will work but -1 is the returned value
        Me.lblMtgDates.Visible = True
        Me.txtEmplOrMtg1.Visible = True
        Me.txtEmplOrMtg2.Visible = True
        Me.txtEmplOrMtg3.Visible = True
    End If
        
End Sub
Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Hi....

May be try this..

<code>

Private Sub ckWOM_Change()

If Me.ckWOM Then
Me.lblMtgDates.Visible = True
Me.txtEmplOrMtg1.Visible = True
Me.txtEmplOrMtg2.Visible = True
Me.txtEmplOrMtg3.Visible = True
Else
Me.lblMtgDates.Visible = False
Me.txtEmplOrMtg1.Visible = False
Me.txtEmplOrMtg2.Visible = False
Me.txtEmplOrMtg3.Visible = False
End If
Me.refresh
End Sub


<code>
 
Hi,

I'm not sure the CheckBox had a Change event but it did give me an idea. If you want the labels and textboxes to appear and disappear depending on the checkbox you can eliminate the IF statements:
Code:
Private Sub ckWOM_AfterUpdate()

        Me.lblMtgDates.Visible = ckWOM.Value 'or me.ckWOM
        Me.txtEmplOrMtg1.Visible = ckWOM.Value 'or me.ckWOM
        Me.txtEmplOrMtg2.Visible = ckWOM.Value 'or me.ckWOM
        Me.txtEmplOrMtg3.Visible = ckWOM.Value 'or me.ckWOM
        
End Sub
Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Changing the IF statement to this worked perfectly:

If Me.ckWOM = True Then

Thank you, HarleyQuinn!

 
Glad we could help [smile]

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Hi..

OOPS..

Should have been the ckWOM_Click event/


Do the boxes and label also disappear when you click to take the check out?
 
Hi lewds,

If the OP uses the original code then I doubt that they will (unless some code under the else part of the statement has been omitted), but if they use either of the solutions we posted then the answer would be yes.

Cheers

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top