VBA for toggles

Rockape

Registered User.
Local time
Tomorrow, 00:32
Joined
Aug 24, 2007
Messages
271
Hi all,

Grateful for assistance.

I have three toggles. when i toggle one i want to invalidate the others. Can anyone offer me the code or direct me to the write location.

I've tried On Cick, on lost focus etc..

Thanks :confused:
 
Stick something in the on click of the selected control to say
Code:
Othercontrol1.value=false
Othercontrol2.value=false
But if you use an option group it'll do it for you.
 
Thanks,

Sorry for not replying earlier. Will try that out now.

Thanks again





Stick something in the on click of the selected control to say
Code:
Othercontrol1.value=false
Othercontrol2.value=false
But if you use an option group it'll do it for you.
 
Hi,

Option group sounds a great idea, but can't find it. I'm using 2003!


Regards
 
I forget what the icon looks like in the toolbar but I'm sure Access 2003 has it. I think it looks like a rectangle with XYZ at the top
 
Hi,

used the following and it worked many thanks for pointing me in the right direction.
Option23.Locked = True

Thanks
 
Hi,

No it didnt work!

Hmmmm.... back to the drawing board
 
I didn't think "locked" would be the way to go. How does "selected" or "value" work? Did you find the option group button on the toolbar in form design? Try having a gander in the help file, it might show a picture of it.
 
The option Button is in the Database tools same location you use to add a label or textbox. It is a rectangle with XYZ on the top of the rectangle. In the option you can only have one value for the group.
 
As described above. I knew it was the same in 2003!
 
Hi all,

thanks for your comments . I did find the option group but i now have a diffrent problem.

My task is as follows I have say two options.

Case 1: I toggle the first one on the form then I enter the datae parameters in the form. The preview button should then do the following, if the first toggle is on then print report 1 for the date range given.
Case 2: if i toggle the second one with the date parameters entered then report 2 should appear when i press the preview button.

I want to include the code on the button but I dont know how to control the toggles on or off or 1 or zero.... i've tried all sorts but it wont budge!

grateful for assistance.

Thanks



As described above. I knew it was the same in 2003!
 
Just use an if or select case statement in the on click of your button:

If optiongroup.value=1 then

Open report 1

Else if opriongroup.value=2 then

Open report 2

Endif
 
Gosh,


what an ..... ive been. I forgot that the checkbox has an assigned value, i.e.1, 2 and 3

I was writing:

If optiongroupA.value=true then

Open report 1

Else if opriongroupB.value=true then

Open report 2

Endif[/quote]


Just use an if or select case statement in the on click of your button:

If optiongroup.value=1 then

Open report 1

Else if opriongroup.value=2 then

Open report 2

Endif
 
Ah that'll be why it's not working then :) surprised it didn't come up with an error to honest.... but that's MS for ya :)
 
Ah that'll be why it's not working then :) surprised it didn't come up with an error to honest.... but that's MS for ya :)
It wouldn't really because they're numbers and numbers can be casted to a boolean value, they're interchangeable.

Try this in the immediate window:
?Cbool(1)
?Cbool(2)
?CBool(-1)

even
?Cbool("23")

?CInt(True)
?CInt(False)
 
Of course, if the values were -1 and 0 that would have worked too - I didn't think you could have negative numbers as values in option groups, love coming here and learning bits like this! You're a cleverun VBA
 

Users who are viewing this thread

Back
Top Bottom