Link to home
Start Free TrialLog in
Avatar of mcn
mcnFlag for Afghanistan

asked on

Toggle Button Basics

I've never used a toggle button on a form and cannot find a clear, basic intro.  I have a form based on a table.  One of the fields is the Y/N Boolean type.  The form (call it B) is based on a query that filters to the desired record (based on selections in a prior form (call it A).)   The user will be allowed to modify certain of the fields in the underlying record, one of which is the Boolean.  I'd like to use a toggle button to allow them to "switch" the choice (in this case a -1 (True/Yes) = "Open", and 0 (False/No) = "Closed"   If you can point me to a decent intro. on how to set this up, I'd appreciate it.  Thanks!
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

See if you can use this information, I didn't quite your question:

Have a toggle button fotm the tool bar.

In its caption enter "See Table B"  assuming you are by default seeing Table A.

In the on click event of the toggle button (say nammed toggle1) have

If toggle1= false then 'false means it is up not pressed
  me!toggle1.caption = "See Table B"
Else
  me!toggle1.caption = "See Table A"
End If

Mike
If toggle1= false then 'false means it is up not pressed
  me!toggle1.caption = "See Table B"
  'run code 1
Else
  me!toggle1.caption = "See Table A"
    'run code 2
End If
Avatar of Ryan
If you use the option frame button, the wizard should be pretty simple.
I think I would use a command button though. Setting the buttons caption based on that boolean field.

Similar to eghtebas' 2nd suggestion.

cmdButton.caption = iif(Field1,"Open",Closed")    

Put this code in the cmdButton_Click event and also form_current (so it'll set the command button text when you go to new records)
ASKER CERTIFIED SOLUTION
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mcn

ASKER

Wording was somewhat cryptic.  Otherwise right on!
Thats fine. I was just giving alternative methods. (Forgot the line to toggle the field value though). 2 Lines vs 7, options are good.

Field1 = not field1
cmdButton.caption = iif(Field1,"Open",Closed")