-
problem with BuildCriteria and text fields
Hi,
I am having some difficulty getting the following code fragment to work:
[VBA]Private Sub Combo10_Change()
Dim FormFilter As String
Dim FiltField As String
Dim FiltCrit As String
If Form_Table1.Combo10.Value = "Joe" Then
FiltField = "Name"
FiltCrit = "Name=Joe"
FormFilter = BuildCriteria(FiltField, dbText, FiltCrit)
Else
FormFilter = ""
End If
Form_Table1.Filter = FormFilter
Form_Table1.FilterOn = True
End Sub[/VBA]
Basically, when this runs it brings up a dialog box that is captioned "Joe", rather than automatically filtering for names = Joe. I use a comparable syntax for boolean and date filters, and they seem to work fine, but for some reason this doesn't work smoothly for text fields.
Thanks, Aaron.
-
Solved! I'm now using:
FiltCrit = "Name='Joe'"
-
Just be careful if using this method on a text field that might contain ' in the text (such as O'Brien). You might want to try
FiltCrit = "Name=""Joe"""
Or if you're like me and get confused with too many quotes,
FiltCrit = "Name=" & Chr(34) & "Joe" & Chr(34)
-
Thanks, I'll incorporate yr suggestion!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules