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!

VBA Access Question

Status
Not open for further replies.

bbyboo1323

Programmer
Apr 10, 2003
10
US
Ok heres the situation. I have to add a label to a form in which when a check box is checked, the label is not visible and when its not checked, it is visible. I have entered the code as follows:
Public Sub CurrentLabel()
If [Current].Enabled = True Then
lblInactive.Visible = False
Else
lblInactive.Visible = True
End If

End Sub

Private Sub Current_LostFocus()
Call CurrentLabel

End SubPrivate Sub Form_Current()
Call GPA
Call CurrentLabel

I keep getting an error at the point where its If [Current].Enabled = True Then. so i tried .checked = true and .checked = no and neither work. Someone please help me!! Thanks
 
Generic code for hiding/unhiding a control based on the value of a checkbox:

Sub ShowMyLabel
ControlName.Visible = CheckBoxName
End Sub

or...
Sub HideMyLabel
ControlName.Visible = Not CheckBoxName
End Sub

Labels can't get the focus... and they don't have the Enabled property...

Good luck



[pipe]
Daniel Vlas
Systems Consultant

 
1) learn to name your controls with a naming conventions (eg chkCurrent as the checkbox)
2) In Access VBA on the forms .. you'd need the following :

Public Sub chkCurrent_Click()
lblInactive.Visible = chkCurrent
End Sub

This will change it on the click. Access forms hold checkboxes as true, false and null, so as long as its not null you should be ok with that. You can ofcourse put that code into the onCurrent event of the form too.

Vince
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top