By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

How Can You Enable a Command Button After 8 Toggle Buttons are Clicked?

P: 12
Hi everyone,

I am working on a project for work and I have an issue that has been holding me up. On a form in Access, there are 8 fields which all have toggle buttons next to them. Management wants the "Save Record" button to be locked until all of the toggle buttons have been clicked, at which point the user can click the save button and the record will be saved. I have tried macros and coding and can't seem to figure it out. I have attached a picture of the form. Any help is much appreciated.

-Eric
Attached Images
File Type: jpg Capture.jpg (81.7 KB, 69 views)
Feb 26 '18 #1

✓ answered by PhilOfWalton

Probably not the way I would handle it.

I assume that you want to check there is a valid entry for the eight fields.
I also assume that each of these fields is bound to the Primary Key of some sort of "Lookup Table".

In that case I would make each of the queries for the rowsource of the combo box a Union Query something like
Expand|Select|Wrap|Line Numbers
  1. SELECT FirmID, FirmName FROM TblFirms UNION SELECT 0, "<Choose One>" From TblFirms
  2. ORDER BY TblFirms.FirmName;
  3.  
After update of each Combo box, check the value of all 8 combo boxes, and if all 8 are >0 then show the save button, otherwise the save button stays hidden.

Than way you don't need thr red buttons.

Phil

Share this Question
Share on Google+
6 Replies


gnawoncents
100+
P: 212
Eric,

You could write a procedure that checks the state of each toggle. If all have been clicked, then the Save Record button is enabled. If not, it is disabled. Call it when the form opens (disabling the button) and then in the After Update event of each toggle button. That way when each has been clicked, the button will enable.
Feb 27 '18 #2

PhilOfWalton
Expert 100+
P: 1,430
Probably not the way I would handle it.

I assume that you want to check there is a valid entry for the eight fields.
I also assume that each of these fields is bound to the Primary Key of some sort of "Lookup Table".

In that case I would make each of the queries for the rowsource of the combo box a Union Query something like
Expand|Select|Wrap|Line Numbers
  1. SELECT FirmID, FirmName FROM TblFirms UNION SELECT 0, "<Choose One>" From TblFirms
  2. ORDER BY TblFirms.FirmName;
  3.  
After update of each Combo box, check the value of all 8 combo boxes, and if all 8 are >0 then show the save button, otherwise the save button stays hidden.

Than way you don't need thr red buttons.

Phil
Feb 27 '18 #3

twinnyfo
Expert Mod 2.5K+
P: 3,055
Eman1234,

I am on board with Phil. I would go one step further and disable all the Combo Boxes on a new record except the first, and the User can only enter data into the first Combo Box. When an item is selected from the first Combo Box, if it is a valid value, then enable the next Combo Box:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboSalesRegion_AfterUpdate()
  2. On Error Goto EH
  3.  
  4.     Me.cboFirmID.Enabled = (cboSalesRegion <> 0)
  5.     Me.cboFirmID.SetFocus
  6.  
  7.     Exit Sub
  8. EH:
  9.     MsgBox "There was an error:" & vbCrLf & vbCrLf & _
  10.     "Error Number: " & Err.Number & vbCrLF & _
  11.     "Description:  " & Err.Description
  12.     Exit Sub
  13. End Sub
Repeat these steps for each Combo Box, if the last one has a valid value, then enable the Save Button.

Hope this hepps!
Feb 27 '18 #4

PhilOfWalton
Expert 100+
P: 1,430
With great respect, Twinnyfo, one step too far.

Having used your routine, and say filled in 5 combos, then for some peculiar reason set say combo2 back to the default value, the other values can still be set and the record saved.

The way that I suggested you need a single function "CheckCombos" which will show the save button if all 8 Combos are OK.
Just run CheckCombos on the AfterUpdate of each Combo Box

Phil
Feb 27 '18 #5

twinnyfo
Expert Mod 2.5K+
P: 3,055
Phil,

Yes, I see your point. One function could accomplish the same end result. My reply was not exhaustive, but more descriptive.

Thanks for providing more clarification, and perhaps, more complete guidance on this quesiton!

:-)
Feb 27 '18 #6

P: 12
This worked! Thank you gnawoncents, PhilOfWalton, and Twinnyfo! Couldn't have done it without you. Wish you all the best.
Feb 27 '18 #7

Post your reply

Sign in to post your reply or Sign up for a free account.