greyed out inaccessible fields

eric1066

Registered User.
Local time
Today, 21:32
Joined
Nov 13, 2009
Messages
11
Hi,

I'm a complete noob and was hoping someone could help me out here. I have tried looking around for the answers but I dont understand the answers!

Basically, I have a form which ask for certain details, say, Name and Date of birth. As there is a possibilty of joint applications I have included in my table more fields for the second applicants name and date of birth. I have also created a field with a yes/no checkbox if it is a joint application.

What I want is for the form to have the 2nd applicant fields greyed out (as in inaccesible) unless the joint application checkbox on the form is ticked.

Any help greatly appreciated,
Eric1066
 
When the user clicks on the check box you need to respond to the value of the check box.

Code:
If Me.CheckBox = True then
   Me.TextBox.Enabled = True
Else
   Me.TextBox.Enabled = False
End If

David
 
You'll also need to place this code in the Form_Current event in order for the textbox to be enabled/disabled according to each record's checkbox value..
 
Last edited:
bit more explanation

the enabled and locked properties work together

enabled locked
true......false..... normal field
true......true...... you can enter the field but cant change it - but you can search/sort/filter
false.....true....... you cant interact at all
false.....false...... produces greyed effect (and you cant interact, obviously)
 
thanks so much for the responses, but I am new to this and not sure what to do here. Where do I put this code? do I copy it exactly or am I to change it in someway? does 'me' mean my name? What screen should I be in when I type this the table or the form?

Your help is greatly appreciated!
Eric1066
 
To get to the code module for your form, from Form Design View go to the View menu then click on Code. In the code module behind the form place the code below, after making these modifications:

Replace YourCheckBoxName with the actual name of your checkbox.

Replace TargetTextBox with the actual name of the textbox you want to gray out . You can apply the formatting to other controls at the same time by simply including then in a similar manner.

Code:
Private Sub Form_Current()
 If Me.YourCheckBoxName = True Then
   Me.TargetTextBox.Enabled = True
 Else
   Me.TargetTextBox.Enabled = False
 End If
End Sub

Private Sub YourCheckBoxName_AfterUpdate()
 If Me.YourCheckBoxName = True Then
   Me.TargetTextBox.Enabled = True
 Else
   Me.TargetTextBox.Enabled = False
 End If
End Sub

The Me refers to the current form. It's shorthand, if you will. Instead of having to write out the form name and then the control name each time you refer to the control, you can simply write Me.ControlName.

Another point should be added here, I think. Those of us who answer questions here on a regular basis, all of whom are volunteers, do so in order to help people who are just beginning to learn Access. We're always happy to help resolve problems and give advice on particular points/problems that posters are experiencing. But we are not here to develop entire databases for people.

We expect the posters to have taken the time to at least learn the ABCs of Access development, and to have made an effort at solving their problems before posting here. The questions in your second post in this thread would appear to indicate that you really haven't taken the time to do this, and you absolutely must. Go to your library or bookstore and start with a basic book on Access development. A "Dummies" book is always a good start! Read it from cover to cover. It'll teach you what the various objects are; tables, forms and queries, etc. and what their functions are. It'll teach you the correct names of all controls, and in a general way, how things are done.

Good luck with your project.
 
Thanks for your reply, I really appreciate it!

You are quite right, I am out of my depth here. I have started reading a 'dummies' book and I am finding it too trivial and telling me things I already know! I have sinced ditched this and began reading a VBA book and have learnt quite a bit! But, knowing these terms still doesn't help me with my specific problems. I find that the explanations and examples are of situations I am not in, do not need, or far too simplistic. If I could find some basic code that is geared toward what I am doing, then I could 'attempt' to adapt it, that would be something!

Right now, I am plodding along, and with the forums help I may get there one day, help may I add that is currently free. I am willing to pay to get more specific type questions answered because of my 'beginner status.' If anyone is interested let me know!!

Thanks.
Eric1066
 

Users who are viewing this thread

Back
Top Bottom