Checking Checkbox Problem

databasedonr

Registered User.
Local time
Today, 14:34
Joined
Feb 13, 2003
Messages
163
I am trying to check the value on a check box that corresponds to another checkbox on the same form. Here is the code I am using:

With Me
.chkNewIndefinite.SetFocus
.chkNewIndefinite.TripleState = True
If .chkNewIndefinite = Null Then
.IndefiniteDisposal.SetFocus
If .IndefiniteDisposal = Checked Then
.chkNewIndefinite = Checked
ElseIf .IndefiniteDisposal = Unchecked Then
.chkNewIndefinite = Unchecked
End If
End If

And what I am trying to do is:

If the chkNewIndefinite checkbox is not checked, then check the value of the IndefiniteDisposal checkbox. Then, set the value of the chkNewIndefinite checkbox to be the same as the IndefiniteDisposal checkbox.

I want this to execute ONLY if the .chkNewIndefinite checkbox has not been checked - ergo, if it hasn't been changed by the user, make sure the value is the same as the other checkbox.

What happens when I execute this is -- nothing. As you can see, I have made sure I am using the triple state of the control, but when line 4 is read, it immediately ends, regardless of the value of the chkNewIndefinite checkbox!

??? Help, please!
 
databasedonr,

This is mostly for syntax, not logic
Code:
If IsNull(Me.chkNewIndefinite) Then
   If Me.IndefiniteDisposal = True Then
      Me.chkNewIndefinite = True
   Else
      Me.chkNewIndefinite = False
   End If
End If

Wayne
 
Wayne,

That worked a treat -- thank you very much.

If you have the energy/inclination, I would love to hear the "whys" -- I am a code newbie and am trying to cram my brain with as much knowledge as I can.

I particularly like that I don't have to set focus to check the values; I use this logic in several places and this is the first time I 've had a problem with it.

Once again, thanks very much, I appreciate the help.

Don
 

Users who are viewing this thread

Back
Top Bottom