VB Run Time Error '2185'

cursedeye

Registered User.
Local time
Today, 09:42
Joined
Oct 7, 2009
Messages
50
I keep getting an error:

run-time error '2185'
"you can't reference a property or method for a control unless the control
has the focus."

There is no problem with CheckFilter function, I checked.

My Code:

Private Sub Building_AfterUpdate()
Call CheckFilter

Dim sBuildingRoom As String
sBuildingRoom = "SELECT DISTINCT Location.[Location ID],Location.Room " & _
"FROM Building INNER JOIN Location ON Building.[Building ID]=Location.[Building ID]" & _
"WHERE Building.[Building Name]= '" & Me.Building.Text & "'" & _
"ORDER by Location.Room"
Me.Location.RowSource = sBuildingRoom
Me.Location.Requery

End Sub

Thanks
 
Change this

Me.Building.Text

to

Me.Building
 
Oh, and you're going to have a problem with no spaces between text on different lines. It looks like you allowed for it on the first line, but then forgot.
 
actually the filter works when there is result(s), if there is no result it gives me this error.

I use the function "CheckFilter" for some other entries it works fine, when it can't find any match just returns a blank page instead of an error.
 
Have you tried making those changes?
 

Users who are viewing this thread

Back
Top Bottom