VB Run Time Error '2185' (1 Viewer)

cursedeye

Registered User.
Local time
Today, 09:41
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
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 05:41
Joined
Aug 30, 2003
Messages
36,124
Change this

Me.Building.Text

to

Me.Building
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 05:41
Joined
Aug 30, 2003
Messages
36,124
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.
 

cursedeye

Registered User.
Local time
Today, 09:41
Joined
Oct 7, 2009
Messages
50
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.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 05:41
Joined
Aug 30, 2003
Messages
36,124
Have you tried making those changes?
 

Users who are viewing this thread

Top Bottom