Multi filter referencing field on form (1 Viewer)

ECEK

Registered User.
Local time
Today, 20:38
Joined
Dec 19, 2012
Messages
717
Just having trouble getting my filter to work:

Code:
Dim strMyLast As String

strMyLast = "Status <> 'Completed' And User = Me.UserName"

Debug.Print strMyLast

Me.Filter = strMyLast
Me.FilterOn = True

Im trying to filter my form by everything not completed and by the a field called userName that appears on my Form.

Any ideas?
 

sneuberg

AWF VIP
Local time
Today, 12:38
Joined
Oct 17, 2014
Messages
3,506
You need to concatenate Me.UserName into the string otherwise it will be literally Me.UserName instead of its valued. Assuming User is a text field this would be something like:
Code:
strMyLast = "Status <> 'Completed' And User = '" & Me.UserName & "'"
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:38
Joined
Sep 21, 2011
Messages
14,295
Try strMyLast = "Status <> 'Completed' And User = '" & Me.UserName & "'"
 

ECEK

Registered User.
Local time
Today, 20:38
Joined
Dec 19, 2012
Messages
717
Thanks Guys
I tried Gasman's solution and it works perfectly.
Many thanks.
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:38
Joined
Sep 21, 2011
Messages
14,295
Thanks Guys
I tried Gasman's solution and it works perfectly.
Many thanks.

Sneuberg replied first, and my reply is the same as his?:confused:
 

ECEK

Registered User.
Local time
Today, 20:38
Joined
Dec 19, 2012
Messages
717
I just happened to try yours first and it worked ! I didn't need to compare.
 

Users who are viewing this thread

Top Bottom