We help IT Professionals succeed at work.

Toggle Button Basics

mcn
mcn asked
on
Medium Priority
438 Views
Last Modified: 2013-11-28
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!
Comment
Watch Question

Mike EghtebasDatabase and Application Developer

Commented:
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
Mike EghtebasDatabase and Application Developer

Commented:
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
RyanProject Engineer, Electrical
CERTIFIED EXPERT

Commented:
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)
Database and Application Developer
Commented:
the reason I gave the expanded version so it:

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

to include actions to perform.
mcn

Author

Commented:
Wording was somewhat cryptic.  Otherwise right on!
RyanProject Engineer, Electrical
CERTIFIED EXPERT

Commented:
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")

Explore More ContentExplore courses, solutions, and other research materials related to this topic.