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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL query returns 0 records in vba 1

Status
Not open for further replies.
Jun 17, 2004
50
0
0
GB
Hi,

I can't see what I am doing wrong here

I am concatenating an SQL string to replace apostrophe's from surnames so I can stick them in an xml file. I concatentate the query,

strSQL = ""
strSQL = strSQL & "SELECT tblEMSdata.CHILDIDENTIFIERVALUE, tblEMSdata.FAMILYNAME, tblEMSdata.GIVENNAME1, tblEMSdata.GIVENNAME2, tblEMSdata.LINE3 "
strSQL = strSQL & "FROM tblEMSdata WHERE (("
strSQL = strSQL & "(tblEMSdata.FAMILYNAME) Like ""*" & Chr(39) & "*""))"

rst.Open strSQL, CurrentProject.Connection, adOpenKeyset

which then produces the following query,

SELECT tblEMSdata.CHILDIDENTIFIERVALUE, tblEMSdata.FAMILYNAME, tblEMSdata.GIVENNAME1, tblEMSdata.GIVENNAME2, tblEMSdata.LINE3 FROM tblEMSdata WHERE (((tblEMSdata.FAMILYNAME) Like "*'*"))

When I paste this into a new SQL query window within access it returns 141 records but in the vba, rst.recordcount = 0??

help!
 
The wildcard for ADO is %, not *. Are you using ADO?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top