automatic data entry on a form (1 Viewer)

B

briandis14

Guest
I wonder if anyone can help me with this problem. Each department within an organization is assigned a unique 7-digit number. Both the name and the ID number are used on a particular form. What I would like to do is set up this form so that, as the department's number is entered into a field, that department's name would be automatically entered into an adjacent field. I had some luck using a two-column combo box that referenced the names from another table in my database. This table simply lists each department and its number. But, since I changed the 'department name' Record Source to coincide with the first column of the combo box (myfield = [combobox].[column](0)), the value is no longer entered in the table's datasheet. So, I would like the name to be entered automatically in the form's field, but still need both values to show up on the table. If that means leaving the Record Source alone, is there a solution using visual basic? If anyone can help, I'd appreciate it...
 

Jill

Registered User.
Local time
Today, 15:44
Joined
Feb 21, 2000
Messages
18
I don't know if you've solved this problem yet or not, but I've used this code in one of the applications I developed and it seems to be working fine. Try it and see if it works.

Private Sub DeptId#_AfterUpdate()
'This will update your Dept. Name field based on the value selected in the DeptId# field
'Me!DeptName=Me![DeptId#].Column(2)
End Sub


You would of course put the correct field names in place of DeptName & DeptId#. Also, make sure the correct column number is showing.

Hope this helps!
 

Users who are viewing this thread

Top Bottom