Deke
Deke

Reputation: 495

Access VBA filter by User

I'm trying to setup a simple filter button that will filter by the network user ID which is populated in the [Owner] field when a record is created. The idea is to see only the records you created.

the code I'm using is as follows:

Private Sub FilterUser_Click()
Dim Uname As String
Uname = Environ("USERNAME")

Me.Tasks.Form.Filter = [Owner] = Uname '<---- Error debugs this line
Me.Tasks.Form.FilterOn = True

End Sub

I get the following error but I'm confused on what field it thinks is missing.

enter image description here

Any help would be greatly appreciated.

Upvotes: 0

Views: 146

Answers (1)

Warcupine
Warcupine

Reputation: 4640

Filter requires a string value.

me.tasks.form.filter = "[owner]='" & uname & "'" 

Upvotes: 1

Related Questions