applyfilter with a wildcard

G

Guest

I have two fields on my form to filter the underlying dataset, Branch and
Position. I'm trying to use the ApplyFilter method to filter my dataset
instead of using the query itself. The problem happens when one or both
field is blank. The filter looks for records with blank Branches and or
Positions. I know in a query you would use the "Like [Field] & *" technique.
This way if your filed is blank you get all records. How do I do this in
VBA?

Private Sub Branch_AfterUpdate()

Dim stLinkCriteria As String

stLinkCriteria = "[Name] & [Description]=" & "'" & Me![Branch] & "'"

DoCmd.ApplyFilter , stLinkCriteria

'Like Me![Branch] & "*"
'Like Me![ Position] & "*"

End Sub
 
D

Douglas J. Steele

stLinkCriteria = "[Name] & [Description] Like "'" & Me![Branch] & "*'"

However, I don't really understand the [Name] & [Description] part on your
part...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top