Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter ADO recordset 1

Status
Not open for further replies.

jozino01

Technical User
Apr 25, 2003
257
CA
hi,

i have a ms access table with
Code:
 field containing the following values:
D1, D3, D5, D6, D7, W1, W2, HP-D1, HP-D2, G-TSE, G-TSD, G-ASE, G-ASD, G-ASV

here is a part of my code:

Dim selGable As String
...
selGable = Left(rs3("Type"), 3)

rs2.Filter = "Code LIKE 'D*' OR Code LIKE 'W*' OR Code LIKE 'H*' OR Code LIKE '*" & selGable & "'"

Set DataGrid1.DataSource = rs2

i want to filter my recordset so it will show all records with [Code] beginning D,W, H and only G-TSE or G-TSD or G-ASE or G-ASD or G-ASV.

right now it shows all records regarding of the selGable value.

this part of code:
rs2.Filter = "Code LIKE 'D*' OR Code LIKE 'W*' OR Code LIKE 'H*'"

works OK, but if i add:
or Code LIKE '*" & selGable & "'
it doesn't.

any idea, please?
 
but how?

if i run this query:

SELECT GDW.Code
FROM GDW
WHERE (((GDW.Code) Like "w*")) OR (((GDW.Code) Like "h*")) OR (((GDW.Code) Like "d*")) OR (((GDW.Code) Like "*ase"));


it works OK.

if i change the filter to this:

rs2.Filter = "Code LIKE 'D*' OR Code LIKE 'W*' OR Code LIKE 'H*' OR Code LIKE '*ASE'"

it doesn't work; it shows all records.
 
>if i run this query

Those are two completely different things.

For the ADODB.Filter property, you can only have the wildcard at the end, or at the beginning AND end. Just not only at the beginning.
 
thanks, i didn't know that.

i changed it to

rs2.Filter = "Code LIKE 'D*' OR Code LIKE 'W*' OR Code LIKE 'H*' OR Code LIKE '*" & selGable & "*'"

and it works ok.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top