Losing my Mind (1 Viewer)

CleverFox

New member
Local time
Today, 01:04
Joined
Apr 23, 2018
Messages
2
Hello Everyone, I'm new to Access and new to VBA so please bear with me. I'm learning as I go essentially, which means watching a ton of YouTube videos, googling, and searching wonderful forums such as this. I'm trying to create a simple Search Form using a combo box. I followed the guides.....checked and double checked the little VBA work I did, and I of course receive an error without understanding why it's giving me an error or how to fix it. It's giving me a Run-time error '3464': Data type mismatch in criteria expression.

Private Sub cboSupName_AfterUpdate()
Dim mysup As String
mysup = "Select * from tbl1EmployeesInfo where ([SupervisorName_ID] = " & Me.cboSupName & ")"
Me.tbl1EmployeesInfo_subform.Form.RecordSource = mysup
Me.tbl1EmployeesInfo_subform.Form.Requery
End Sub


Any assistance would be greatly appreciated :D Thank you
 

Attachments

  • snip.JPG
    snip.JPG
    27.6 KB · Views: 37

CJ_London

Super Moderator
Staff member
Local time
Today, 09:04
Joined
Feb 19, 2013
Messages
16,636
chances are your supervisorname_id field in the table has been set as a lookup field and you are trying to match a text value from your combo to a numeric value in your table.

If so, remove the lookup from the field in the table and ensure your combo is bound to the ID in the rowsource

Note: there is no need to requery if you change the recordsource
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:04
Joined
May 7, 2009
Messages
19,246
Also you must include the supv ID in the combo source. Set the combo Bound Column to column number of this ID.
 

CleverFox

New member
Local time
Today, 01:04
Joined
Apr 23, 2018
Messages
2
Thanks for your help; it halfway fixed the issue. So, by adding single quotes as delimiters and making it so it had the raw data and not a lookup box in my original table, my sorting works! Hooray and thank you so much!

However it created a different problem. Now it'll filter correctly in my subform, but when the filtering is complete all of the tables which have relationships show on the subform as "#Name?". :banghead::banghead::banghead:

I'm halfway there! if anyone knows a solution to this. I've been writing all this done in my Access Notes so I don't ever forget how to solve these problems. Thanks for the assistance!

<3
 

Users who are viewing this thread

Top Bottom