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

Check Box Event 1

Status
Not open for further replies.

ktodaitty

MIS
Apr 22, 2003
19
US
Hi!

#1 How do I change a Check Box to Yes/No format?
#2 What is the event that means the user has indicated "Yes"

Thanks!
 
#1 How do I change a Check Box to Yes/No format?

In the table Design View, select the checkbox field. In the Properties box at the bottom of the screen is a property Format. Select Yes/No from the droplist.

#2 What is the event that means the user has indicated "Yes"

The "event" is that the checkbox is "checked". That is, it has a tick displayed.

However, if you mean what value is stored in the table to indicate that the user has checked Yes, it is a value of 1. A value of 0 indicates that the user has not checked the checbox.

HTH
Lightning
 
lightning is correct except for one thing: Yes = -1. Yes also equals True. No = False = 0.
 
thanks , but I got that far. When I am trying to write code that will make certain fields visible only when the box is checked, I don't know the event to put in. This may be really simple, but I am just starting to use VBA.
 
Use the 'after update' event for the checkbox; set the visiblity of the appropriate controls to the value of the checkbox control.
 
thanks, beetee. What is wrong with my code here:

Private Sub Check54_AfterUpdate()
Dim intCheck54 As Integer

intCheck54 = Check54
If intCheck54 = -1 Then
Me.txtWeekly.Visible = True
Else
Me.txtWeekly.Visible = False
End If
cbxCheck54 = Check54

I am getting the "Invalid Outside Procedure" error....
 
you probably need a me object in a few strategic locations, e.g.

intCheck54 = me.Check54

...

me.cbxCheck54 = me.Check54

although it seems you would get a different error than that...

Anyway, you can be a bit more concise by simply saying:

Me.txtWeekly.Visible = Me.Check54

additionally, assigning a -1 or a 0 to a combobox control seems a bit suspect.
 
you da bomb, beegee. As I say, I'm just a beginner but this visual basic stuff is sort of fun.

CAT
 
It is sort of fun, and very absorbing. I hope you have lots of success!
 
Help!

Can anyone give me an example of code that will make other fields visible/not visible according to whether or not a check box is checked? I have tried everything!



 
I've got three check boxes in this example ("CourseTitleCheck", "MyCheck" and "DeptCheck")
I have several labels, text boxes, or combo boxes I hide or display, depending on which boxes are checked.

This code is kind of ugly, but it works - should give you enough to go on to make yours work:


Private Sub CourseTitleCheck_Click()
If CourseTitleCheck = -1 Then
DeptCheck = 0
CourseTitle.Visible = True
CourseLabel.Visible = True
EENumber.Visible = False
MyCheck.Visible = False
End If
If CourseTitleCheck = 0 Then
CourseTitle.Visible = False
CourseLabel.Visible = False
EENumber.Visible = True
MyCheck.Visible = True
End If
If DeptCheck = 0 Then
DeptCombo.Visible = False
DeptLabel.Visible = False
End If

If DeptCheck = -1 Then
DeptCombo.Visible = True
DeptLabel.Visible = True
End If
exit sub
 
take this line of code:
[tt]
Me.txtWeekly.Visible = Me.Check54
[/tt]
replicate it once for each field whose visibility you wish to control.

Substitute other field names for txtWeekly, or for Check54, as required.
 
Thanks so much for your time. I am just now getting around to reading these but it looks like these replies will be most helpful! Take care.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top