I have the following bit of test code which, in my attempts to learn something about Access 2010 VBA, is based mainly from examples found in "Access 2007 VBA Programming for Dummies".
Dim cnnX As ADODB.Connection
Set cnnX = CurrentProject.Connection
Dim myRecordSet As New ADODB.Recordset
myRecordSet.ActiveConnection = cnnX
myRecordSet.Open "Select [First Name], [Last Name] From [Admissions] WHERE ([Address] Like 'Box 1954')"
myRecordSet.MoveFirst
Debug.Print myRecordSet.Fields("First Name").Value
The above code works i.e the correct "First Name" is printed in the Immediate window.
However, again following an example in the Dummies manual, if the middle line of code is changed to:
myRecordSet.Open "Select [First Name], [Last Name] From [Admissions] WHERE ([Address] Like '*ox 1954')"
i.e. the "B" in "Box 1954" is changed to a wild card character, the code abends with a message indicating a record(s) was not found.
The relevant example code portion in the Dummies manual is:
..... WHERE ([Email] Like '*@aol.com*')" which appears to be the same syntax as my case.
Could anyone please tell me why my code doesn't work...
TIA for any assistance.