?
Solved

Toggle Button Basics

Posted on 2008-01-26
6
Medium Priority
?
417 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!
0
Comment
Question by:mcn
  • 3
  • 2
6 Comments
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 20752125
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
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 20752130
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
0
 
LVL 13

Expert Comment

by:Ryan
ID: 20752656
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)
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 34

Accepted Solution

by:
Mike Eghtebas earned 200 total points
ID: 20752777
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.
0
 

Author Closing Comment

by:mcn
ID: 31425342
Wording was somewhat cryptic.  Otherwise right on!
0
 
LVL 13

Expert Comment

by:Ryan
ID: 20754355
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")
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Get the source code for a fully functional Access application shell with several popular security features that Access VBA application developers desire, but find difficult or impossible to figure out how to code. You get the source code for managi…
Suggested Courses

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question