Solved

Switching between checkboxes problem

Posted on 2006-07-21
4
149 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now