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

Command button disabled upon multiple conditions

P: 4
Hi - I'm using Access 2003.

I have an input form that I'm trying to link to multiple tables. I have a command button that updates all the tables with the ~40 textboxes which the user inputs the values.

I'm wondering if there's a way I can make the command button disabled until the value of the text box differs from that of the input tables. The only way I can think is to have a subroutine for every text box "after update" that compares the values and changed the enabled setting; however, in lieu of writing 40 different subroutines, is there a more efficient way to do this?

Thanks,
Mar 9 '10 #1
Share this Question
Share on Google+
4 Replies


TheSmileyCoder
Expert Mod 100+
P: 2,321
If the form is bound, you could enable the button in the form's Dirty
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Dirty(Cancel As Integer)
  2.   btn_Save.Enabled=True
  3. End Sub
Mar 9 '10 #2

missinglinq
Expert 2.5K+
P: 3,532
That doesn't address the OPs question, Smiley! If this is a bound form, the Form_Dirty event will fire the second a single character is entered in the new record, whether or not the value of the current textbox "differs" from that of the "input tables." If the form is unbound (as it sounds from the description) it won't fire at all.

I think we need a much clearer explanation of what Hiramicus is trying to do here.

Is this form bound or unbound?

Is it your intent that, say, TextboxA's value has to be different from the TextA value of any other record in the underlying table?

Why are you using a single form to enter data for 40 fields in multiple tables?

Welcome to Bytes!

Linq ;0)>
Mar 9 '10 #3

P: 4
Thanks for the Welcome.

To explain what I'm doing a bit more, I'm using an unbound form, which will update ~5 different input tables. Because of nature of the data (and future queries off of this), I needed to use a form that would update different tables; some of the data comes in a 1xn matrix and some of it comes in a nxm matrix.

I guess is there a way to have a global procedure that will apply to the form, rather than having many subroutines (that launch "after update" of specified field/textbox)?
Mar 9 '10 #4

missinglinq
Expert 2.5K+
P: 3,532
I'm assuming that the command button you're referring to is a "save" button for writing the data to the various tables. I think you'll have to
  1. Leave the button enabled
  2. Place validation code in its OnClick event.
  3. Have t he code loop thru all controls and run a DCount() for each one to see if the value already exists
  4. If it does already exist, pop a message box to inform the user and exit the sub, moving back to the offending control

This is a lot of work, but you're trying to do validation on 40 fields, in multiple tables. At least the code would be in a single location.

Linq ;0)>
Mar 9 '10 #5

Post your reply

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