Use List Box to Update 2nd Field

G

Gwen H

I have a form based on a table, Employees. All but one of the fields on this
form is from this table (deptName). The control source for deptName is a
query based on the Employees table. The query creates a list of unique
department names.

What I want to do is make it possible for users to click the deptName list
box (which is based on the query) and have it update the deptID field (which
is based on the table). When the form is submitted, I want the deptName and
deptID fields in the table updated with the values from the form. The code I
have does not work.

Private Sub deptName_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Department] = '" & Me![deptName] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

If you have any ideas how to make this work, or know a better way to do
this, ***please*** let me know.

Many thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top