Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checking a checkbox

Status
Not open for further replies.

skiflyer

Programmer
Sep 24, 2002
2,213
US
I have a form with a checkbox...

when a certain condition is true onload, I want it to start out as checked.

I don't think that I want to actually click it, because that would invoke the onclick method, and I don't want that.

Is there a good way to do this? I'm looking at things and just not finding it, though I'm assuming it's a trivality.

Thanks,
Rob
 
'form Load event
boolFormLoading = true 'declared globally
if SomeCondition then
CheckBox.value = vbChecked
else
CheckBox.value = vbUnChecked
end if
boolFormLoading = False



'Click Event of CheckBox
if boolFormLoading = False then
'Do something
end if

 
seriously, I have to put in a state variable like that?

that's just sloppy... I can do HTML cleaner than that.

Well, at least it works, thanks for the help.

-Rob
 
You don't have to do it with a state variable, it's just clearer to do so since a Checkbox can actually be in one of 3 states (checked, unchecked and grayed).

if you want to do it the sloppy, short way, then:

Check1 = Abs(BooleanFlag)
 
that's certainlly unclear... eesh...

I suppose the only clear and neat way would be to define a constant with the value of Abs(BooleanFlag) and set it there, but considering I have two checkboxes to worry about I'll just deal with the state variable.

Thanks for the information...

what I was hoping for the clear way by the way, was the ability to set the box without invoking the event... but this is effectively just as good.

-Rob
 
but they're constants which trigger the event, I was under the impression that using the value of Abs(booleanflag) didn't trigger the event.

Or is it something else about your code (not using .value or something?) which results in this behavior?

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top