Solved Form selecting incorrect combobox option and not allowing to refilter via combobox.

Methodikal

New member
Local time
Yesterday, 20:14
Joined
Nov 7, 2022
Messages
17
Greetings,

New Problemo. I have a combobox that pulls in the Supervisor name and filters the results in the form by the Supervisor Position ID.

However, when I click on some options it takes me to a different Supervisor (Supervisor Position ID). Then when I try to switch to another Supervisor in the combobox it doesn't change and does not Requery.

Here is my VBA Code:

AllEmployeesEditableF

Option Compare Database
Option Explicit
_______________________________________

Private Sub SupervisorSearchCbo_AfterUpdate()

RequeryFormAllEmployeesEditableF

End Sub
_______________________________________

Sub RequeryFormAllEmployeesEditableF()

Dim strSQL As String

strSQL = ""

If Len("" & Me.!SupervisorSearchCbo3) > 0 Then
strSQL = "[ReportsToFull] = '" & Me.!SupervisorSearchCbo3 & "'"
End If

If Len(strSQL) = 0 Then
Me.FilterOn = False
Else
Me.Filter = strSQL
Me.FilterOn = True

End If

End Sub
________________________________________

Private Sub SupervisorSearchCbo3_AfterUpdate()

RequeryFormAllEmployeesEditableF

End Sub
_________________________________________


Any advice is much appreciated.

Thanks,

Methodikal
 
The Debug is giving me something funny.

When I hover over:

If Len("" & Me.!SupervisorSearchCbo3)

It shows: Me.!SupervisorSearchCbo3 = "50640"

When I hover over:

Me.Filter = strSQL

It shows: strSQL = "[ReportsTo] = '50640'"

So wondering if there may be something causing this.

Error when I Step Out is:

Run-time error '3464':

Data type mismatch in criteria expression.

I hope this helps.
 
I would start by removing the ! in your Me.!SupervisorSearchCbo3
 
If ReportsTo has a numeric data type, you don't want the single quotes around the value.
 
Lol. I figured it out. I was like a dumb dumb I had a circular reference that was confusing the system.

I fixed it. Thanks!
 
Glad you got it sorted out.
 

Users who are viewing this thread

Back
Top Bottom