combo box code problem

  • Thread starter aceavl via AccessMonster.com
  • Start date
A

aceavl via AccessMonster.com

i have a combo box that let's the user choose the employee and company from a
list
and then automaticly puts the selection in the fields of the form.

problem: when i try to add a new record and choose a employee-company it goes
back to the first record. how can i fix this?

Private Sub ccSelect_AfterUpdate()

Dim rs As Object
Dim varEmpNom As String
Dim varCoNom As String

Set rs = Me.Recordset.Clone
rs.FindFirst "[PayID_PK] = " & Str(Nz(Me!ccSelect, 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

'--- get the Emp_Nom and Co_Nom from tblEmp,
'--- compare it to the seleccion
varEmpNom = DLookup("[Emp_Nom]", "tblEmp", "EmpID_PK = Pay_EmpID_Fk")
varCoNom = DLookup("[Emp_Co_Nom]", "tblEmp", "EmpID_PK = Pay_EmpID_FK")

'--- put the Emp_Nom and Co_Nom in the fields
Me.Pay_Emp_Nom.Value = varEmpNom
Me.Pay_Co_Nom.Value = varCoNom

End Sub

by the way, the first part of the code is what access puts when you use the
wizard to make the control.
 
Top