note4shawn
New member
- Local time
- Today, 10:02
- Joined
- Feb 8, 2018
- Messages
- 2
Hello all,
I have a form with a combobox that shows a list of employees from a query. Once an employee is chosen you can open either open a form to edit this employees data or you can open a report to view the data.
I had this working as expected but I had to change the employee number field (which is the field/column that is bound in the combobox) from Number to Text. Now I am getting the "Run-time error '3464': Data type mismatch in criteria expression" when I choose an employee. I have made sure that all the employee number fields that this field is linked to are also Text data types. All my queries work so this data type mismatch must have to do with the code. The following is the code that is attached to the combobox AfterUpdate().
Private Sub Combo24_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[emp_number] = " & Str(Nz(Me![Combo24], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
When I debug the red text is highlighted. I am not really fluent in coding. I know just enough to piece things together and make them work. I am not sure exactly what is wrong with this code other than it obviously must only be for Number data types.
Can someone tell me how I can fix this code to work with Text data types? Or am I completely wrong and it is something else?
I have a form with a combobox that shows a list of employees from a query. Once an employee is chosen you can open either open a form to edit this employees data or you can open a report to view the data.
I had this working as expected but I had to change the employee number field (which is the field/column that is bound in the combobox) from Number to Text. Now I am getting the "Run-time error '3464': Data type mismatch in criteria expression" when I choose an employee. I have made sure that all the employee number fields that this field is linked to are also Text data types. All my queries work so this data type mismatch must have to do with the code. The following is the code that is attached to the combobox AfterUpdate().
Private Sub Combo24_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[emp_number] = " & Str(Nz(Me![Combo24], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
When I debug the red text is highlighted. I am not really fluent in coding. I know just enough to piece things together and make them work. I am not sure exactly what is wrong with this code other than it obviously must only be for Number data types.
Can someone tell me how I can fix this code to work with Text data types? Or am I completely wrong and it is something else?