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

How to uncheck a box within a frame that have several boxes

Status
Not open for further replies.

maupiti

Programmer
Oct 27, 2003
240
US
I have a frame, and in this frame there are three check boxes (A, B and C). Only one check box can be check at any one time. If A is checked, and I clicked on B, then B is checked, but A is unchecked.

Initially, none of the boxes are checked, but as soon as one is check (say A), I cannot uncheck this box. How do I uncheck this box using VBA code ?

////////////////////////////////////////////

Private Sub Frame_1_Click()
If Frame_1.Value = 1 Then
Frame_1.Value = 0
Else

If Frame_1.Value = 0 Then
Frame_1.Value = 1
End If

End If
End Sub
 
Hi Remou. Thank you for your help.
I did as you have suggested, but when clicked on
the box that is checked, it remains uncheck.

//////////////////////////

Private Sub Frame_1_Click()
If Frame_1.Value = 1 Then
Me.Frame_1 = Null
Else

If Frame_1.Value = 0 Then
Me.Frame_1 = 1
End If

End If
End Sub
 
You need to put the line outside the frame, maybe a command button, or an On Current Event. Is this frame is unbound?
 
Hi Remou. It does work if I put it in a button.
However, in a form where there several frames and
each frame has about five check box, that would mean that
I have to add several more buttons (one to each frame) to uncheck the check box. This will make the form more crowded to the user's eyes, take a form longer to load, and it makes a user have to push a button to uncheck a check box.

A better method would be to have a VBA code to where if a user check on a box that is already check, the box would uncheck. This makes the form more cleaner, and more intuitive to use for the user.

If there is a way to uncheck the box when you click on a check box that is currently checked then please let me know.
 
The trouble is that if you click an option that has already been clicked, a click event does not occur. So I see two possibilities:
1. Add another option for Blank, lets call it option 4
[tt]Private Sub fraFrame_AfterUpdate()
If Me.fraFrame = 4 Then Me.fraFrame = Null
End Sub[/tt]

Use a double-click event:
[tt]Private Sub fraFrame_DblClick(Cancel As Integer)
Me.fraFrame = Null
End Sub[/tt]
That's all I can think of ...
 
Why not use a Option Group with radio buttons. When one is clicked, the others will automatically uncheck.
 
How are ya maupiti . . .

I agree with [blue]hneal98[/blue]. An [blue]Option Group[/blue] would be perfect. You can also adjust frame sizing to match your origional . . .

Calvin.gif
See Ya! . . . . . .
 
Hi hneal and Aceman
maupiti - original post said:
I have a frame, and in this frame there are three check boxes (A, B and C). Only one check box can be check at any one time.

This sounds very like an option group to me, especially when the quoted code is Private Sub Frame_1_Click(). I am not sure you noticed that maupiti wishes to return the (as I believe) group to null after an option has been selected. [ponder]
 
i 100% agree with Hneal98 it should be done with radial buttons BUT if you still want to use the checkbox way it goes somthing like this

Code:
 Private Sub cmdhit_Click()
If Check0.Value = True Then
Check2.Value = False
Else
Check2.Value = True
End If
End Sub
 
When I create an option group (Access 2000), I am given a choice of Option buttons, Check boxes and Toggle buttons. It is still an option group, it just contains check boxes (or toggle buttons, whatever). I believe, based on Maupiti's statement that "Only one check box can be check at any one time", that s/he has created such a group. In what way would changing the group to option buttons (radial buttons, whatever) help to uncheck all options, which is what was asked?
 
Remou,

I think you are correct on what the OP was wanting to do. Couldn't you use the mousedown event for each check box to toggle being checked or unchecked? Would still be easier to have a command button, but the OP could build a function to toggle checked or unchecked and call the function on the mousedown event of each checkbox without the added command button.

lwells
 
lwells, when I tried that I found a mouse down only fired when the frame itself was clicked, in my post stamped 23 Dec 05 17:29, I suggested a double-click event or an additional option, both of which work, but neither is exactly what the OP wants, as described in her / his post of 23 Dec 05 16:55.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top