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

Enable/disable controls on a Tabulated Form

P: 15
Hi all,

This is my first post, so please excuse if i am posting a silly question.

I have an MS Access database and have created a tabulated form (where there are multiple lines, one for each record - similar to a table, hence the name). There are about 10 fields or so, and i have used textboxes, combo-boxes and checkboxes to represent the fields.

What I am trying to do is to enable or disable textbox_2, depending on the value of textbox_1 for the *same* record. I have tried using VBA code in the AFTER_Update event but the problem is that when i update textbox_1, it disables or enables textbox_2 for *all* records.

Is there a way I can tell Access to only disable/enable textbox_2 for the *same* record?

Your help is much appreciated.
Oct 23 '06 #1
Share this Question
Share on Google+
4 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
The short answer is no.

However, although the textbox will be disabled for all records you can reset it to enabled in the OnCurrent or OnActivate event in the form so that when you move to the next record the textbox will be enabled again.
Oct 23 '06 #2

P: 15
Hi mmcarthy,

I've tried to do as suggested but could not get it to work. Could you go into that solution with a bit more detail, that is what i should be telling each control/form event to be doing?

Much appreciated.
Oct 26 '06 #3

NeoPa
Expert Mod 15k+
P: 31,476
You could try putting in some code in the 'OnCurrent' event.
It wouldn't set it all up as the records display, but it would ensure the operator could only ever enter fields that were ok by your code.
Oct 26 '06 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_OnCurrent()
  3.  
  4.     If Me.textbox_1 = "some string" Then
  5.         Me.textbox_2.Enabled = True
  6.     Else
  7.         Me.textbox_2.Enabled = False
  8.     End If
  9.  
  10. End Sub
  11.  
  12.  
By putting this value in the forms on current event it will run each time the form record changes.

If you are using tabbed pages you should be able to run this instead in the on change event of the tab control.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub TabCtlName_Change()
  3.  
  4.     If Me.textbox_1 = "some string" Then
  5.         Me.textbox_2.Enabled = True
  6.     Else
  7.         Me.textbox_2.Enabled = False
  8.     End If
  9.  
  10. End Sub
  11.  
  12.  
Oct 26 '06 #5

Post your reply

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