Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to disable fields in Access 2000 & how to combine fields

Status
Not open for further replies.

Hermanator

Technical User
Jan 16, 2002
30
NL
Hello,

I'm creating a database and I'm wondering wether the following option exists.
I want to a field to depend on another field. Is this field has a certain value, I want the other field to be disabled.(Although I'm not sure wether fields can be disabled at all.) What I mean with 'disabled' is that for example the field becomes gray and you cannot change the contents.

I'll give a short example of what I'm trying to make:
In one field you can enter wether someone is student or not. If the person is a student, then I want to be able to enter his student number in the next field. If he is not a student, than I want that field to be disabled.


I also have a second question:
Is it possible in Access to compose a field's value from other fields? Suppose I want to make a field containing a code that is the combination of two strings. In Excel you can just simply type: =A2&"some text"&A3. Is this also possible in Access ?

I really hope you can help me. In any case: thanks a lot!
 
The answer to pt. two:

=
![field]&
![field]
 
Hermanator,
The answer to both questions is Yes they can be done.
Q1: in the "After Update" procedure of your persontype (Since you didn't give the field name, I'm using "persontype". this represents your student or teacher field and "idnumber" for your ID Number field.) field insert the [Event Procedure] option, click on the command button to the right of the cell with the "..." on it and enter the following code:
if me.persontype = "Student" then
me.idnumber.enabled=true
else
me.idnumber.enabled=false
end if
Then copy this and paste it into the OnCurrent Procedure. You'll need to go to the form properties, put an [Event Procedure] in the "On Current" property and go to the "..." command button to paste in the code.
Q2: If these two fields are on your current form, the code to put into the Control Source is, as you assumed, very similar to Excel: [forms]![your form name]![your first field name]&"some text"&[forms]![your form name]![your second field name]. This joins two text fields. If your first and second fields are numeric and your trying to add, subtract, etc, then replace the center &"some text"& with the operator (+,-,*,/)
Hope this helps :)
JimStevens
 
Many, many thanks for your help!

I've managed to disable the fields just like I wanted to. But I still have a problem with point 2.
I don't know where to insert the text
=[form]![fieldname]&"text"
You say I have to put it in the Control Source. Where is that?
What I would like best is that the fields DEFAULT value is the combination value of two other fields, but that the field can be changed if necessary.

I hope you can help me finish the problem.

Herman.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top