Solved

Switching between checkboxes problem

Posted on 2006-07-21
4
156 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

717 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