mardi 3 mars 2015

Access VBA recordset string comparison not working with wildcard

I have loads of experience using VBA in Excel but very little experience using VBA in Access 2010. I'm trying to delete records from a recordset where one of the fields ends in "_X". When I use a wildcard the comparison fails. When I use a specific string, the comparison works as expected. Here is the Code that I am using.



Dim db As Database: Set db = CurrentDb
Dim tbl As Recordset: Set tbl = db.OpenRecordset("WRITEON")
With tbl
Do Until .EOF
If ![ACOD] = "*_X" Then '"$ICP_X" works
Debug.Print ![ACOD] 'For testing
'.Delete
End If
.MoveNext
Loop
End With
tbl.Close


Your suggestions are greatly appreciated.


Aucun commentaire:

Enregistrer un commentaire