473,327 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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

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, 132 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

6 1192
gnawoncents
214 100+
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
1,430 Expert 1GB
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
3,653 Expert Mod 2GB
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
1,430 Expert 1GB
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
3,653 Expert Mod 2GB
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
This worked! Thank you gnawoncents, PhilOfWalton, and Twinnyfo! Couldn't have done it without you. Wish you all the best.
Feb 27 '18 #7

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

Similar topics

4
by: MJW | last post by:
Is there a way for me to know if or which command button was just clicked that triggers the LostFocus event for the current control on a Form? I have a form that has many types of users who each...
11
by: MLH | last post by:
Why is that? If I choose the tiny check boxes which are hard to hit with a mouse, it works fine. But option buttions, shich can be sized big enough for people with limited sight and dexterity...
3
by: Paul Hodgson | last post by:
I have quite a few pages that have multiple command buttons on them - for example one button might be to logout, and others might be to display different segments of the data being shown. The...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
1
by: Jason | last post by:
I was just wondering if there was any way to create a command button that when clicked will launch a cmd prompt and automatically paste the value of a field into the prompt? Thanks for you hellp...
0
by: Chas Large | last post by:
Hi All, I have written a small program which has command buttons to operate a device by remote via RS232. It sends a series of commands when a command button is clicked and held down and stops...
2
by: John Smith | last post by:
How can I use a transparent command button to change a checkbox? I have my records set up in a continuous form and I want theuser to be able to click on the record and have this toggle the...
3
by: Scldb | last post by:
I have a form that is linked up to the tables. I turned off the Navigation buttons. I put in a new command button that when clicked, it opens up a new record. What is the code that is needed for this...
0
by: mesadobes | last post by:
I am very new to visual basic. Actually, I have no clue what I'm doing! But I know what I want to do. I am trying to learn as I go... How do I create a command button that when clicked will...
2
by: Chuck | last post by:
How can I make an array of command buttons (or toggle buttons) on a form and have a text box on the same form display the index of the button clicked? This works very well in VB6, but I can't...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.