• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

Switching between checkboxes problem

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
Yury Merezhkov
Asked:
Yury Merezhkov
  • 2
  • 2
1 Solution
 
Rob_JeffreyIT/ProgrammingCommented:
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
 
Yury MerezhkovDevelopment Team LeadAuthor Commented:
Same thing, i have to click one checkbox twice to deselect the second one
0
 
Rob_JeffreyIT/ProgrammingCommented:
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
 
Yury MerezhkovDevelopment Team LeadAuthor Commented:
They are both not checked when the form loads. Well, I guess I'll go with option boxes. Thanks, anyways.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now