Connecting Tech Pros Worldwide Help | Site Map

DoCmd.Applyfilter

Robert_5032@yahoo.com
Guest
 
Posts: n/a
#1: Nov 13 '05
I cant get my filter to work with variables
Its working fine if I "hardcode" the issueType I want to filter on.

Works fine:
DoCmd.ApplyFilter , "issueType = 1"

Works NOT:
DoCmd.ApplyFilter , "issueType = currentType"

where currentType is a variable with the number of my type of issue.
A messagebox tell me that currentIssue really hold the right value...
Di I need to have any more symbols around a variable name?

Thankyou for any help!
(Im a new Access user and I really love Access!)

Robert

Salad
Guest
 
Posts: n/a
#2: Nov 13 '05

re: DoCmd.Applyfilter


Robert_5032@yahoo.com wrote:
[color=blue]
> I cant get my filter to work with variables
> Its working fine if I "hardcode" the issueType I want to filter on.
>
> Works fine:
> DoCmd.ApplyFilter , "issueType = 1"
>
> Works NOT:
> DoCmd.ApplyFilter , "issueType = currentType"[/color]

DoCmd.ApplyFilter , "issueType = " & currentType
should work.
[color=blue]
>
> where currentType is a variable with the number of my type of issue.
> A messagebox tell me that currentIssue really hold the right value...
> Di I need to have any more symbols around a variable name?
>
> Thankyou for any help!
> (Im a new Access user and I really love Access!)
>
> Robert
>[/color]
Robert_5032@yahoo.com
Guest
 
Posts: n/a
#3: Nov 13 '05

re: DoCmd.Applyfilter


Salad
It worked like a dream!
(I will NOT tell hove many ours I have spent on this...)
Thanks again!
Robert

Salad
Guest
 
Posts: n/a
#4: Nov 13 '05

re: DoCmd.Applyfilter


Robert_5032@yahoo.com wrote:[color=blue]
> Salad
> It worked like a dream!
> (I will NOT tell hove many ours I have spent on this...)
> Thanks again!
> Robert
>[/color]
That's funny. It's happened to all of us where we get so involved that
we see the forest but not the trees.

One other thing. I've never used ApplyFilter. No reason why I haven't
except that I use another method that works fine too.

I may have a series of combo boxes that will create a filter. And I'll
call a routine to build the filter based on entries/selections made. Ex:
Dim strFilter As String
strFilter = "ActiveEmployee = " & Me.ComboActive
If Not IsNull(Me.City) Then
strFilter = strFilter & " And City = '" & Me.City & "'"
endif

Then I enter
Me.Filter = strFilter
Me.FilterOn = (strFilter > "")

So...I like setting Me.Filter and Me.FilterOn.
Closed Thread


Similar Microsoft Access / VBA bytes