Automating values for a field

deere8585

Registered User.
Local time
Today, 13:28
Joined
Jun 26, 2008
Messages
27
Hi all,

I have a form for entering record information into a table- within this form there are 2 fields (that correspond to 2 fields within the underlying table) that I would like to auto populate with information to save the user having to manually type this in every time they enter a new record.

The first field is a text field to specify who has entered the record, I would like this field to be automatically stamped with the current logged on user, the only way I seem able to diaplay this on the form at the moment is to change the control source of the field to =[currentuser], this then displays the correct info on the form but the corresponding field in the table is not populated with this info.

The second field I am struggling with is a field for the customers telephone number.

What i would like to happen is that when the user adds a new record and selects a customer, the telephone number stored with that customers id in the customers table populates the field in the form and is stored the underlying field in the table-however this fiels needs to be able to be overwritten as it is possible that a different number is best to contact the customer on in that particular case.

Again I thought I had achieved this by changing the control source of the filed but with the same problems as described above.

Many thanks in advance for any/all help recieved!!!!
 
For the first, instead of setting the control source to that, set the default value to it.

For the second, presuming you're choosing the customer from a combo, add the phone number field to the combo's row source, and in the after update event of the combo:

Me.TelephoneNumberField = Me.ComboName.Column(x)

where x is the column containing the number.
 
Hi pbaldy,

On the first issue many thanks, that's worked exactly how i'd hoped.

On the second issue-you are right in your assumption that I'm using a combo box.

So from the records table design- for the customer field I have used a lookup wizard, selected my customers table & used customer id, customer name, telephone number-so my presumption would be that my customers telephone number would be column 3.

I've then added the code you suggested into the after update event for my customer combo box on the form but it seemd to return blank values- I've tried building the relationships between the two tables again & deleting then re-ading the customer field into the form but with no success, have I done something wrong here?
 
The column property is zero based, so the third column would be 2.
 
Thanks again this also now works superbly! I very much appreciate your time to help a newbie.
 
No problemo; good luck with the project.
 

Users who are viewing this thread

Back
Top Bottom