Solved

Switching between checkboxes problem

Posted on 2006-07-21
4
153 Views
Last Modified: 2010-04-30
Hi experts,

I have two checkboxes on my form. When the first one is selected i wanna deselect the other one.
My code does that but only when I click second time on the first checkbox. Any ideas y?

Private Sub EmptyDate_AfterUpdate()
    If Me.EmptyDate.Value = 0 And Me.JustEmpty.Value = -1 Then
        Me.EmptyDate.Value = -1
        Me.JustEmpty.Value = 0
    End If
End Sub
0
Comment
Question by:RealSnaD
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Rob_Jeffrey
ID: 17157978
If you only want one selected at any given time you should be using option buttons.

However -

Private Sub JustEmpty_Click()
    If JustEmpty.Value = vbChecked Then EmptyDate.Value = vbUnchecked
End Sub

Private Sub EmptyDate_Click()
    If EmptyDate.Value = vbChecked Then JustEmpty.Value = vbUnchecked
End Sub


If I read your question correctly.
0
 
LVL 7

Author Comment

by:RealSnaD
ID: 17158003
Same thing, i have to click one checkbox twice to deselect the second one
0
 
LVL 9

Accepted Solution

by:
Rob_Jeffrey earned 125 total points
ID: 17158023
Are they being loaded with values on startup?  Such as both being checked when the form loads?
You will need to add code on the form load to ensure only one is checked.
0
 
LVL 7

Author Comment

by:RealSnaD
ID: 17158257
They are both not checked when the form loads. Well, I guess I'll go with option boxes. Thanks, anyways.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question