M
marcbell
Good afternoon,
The below query works when the string value has no apostriphies e.g
jack wines, however it crashes over when it's Jack's wines.
I had a play about with speech marks and apostrophies and I just can't
get it right. I'm sure theres a quick fix, but i can't see it.
Many thanks in advance,
Marc
Sub get_cust_all()
Path = "D:\Documents and Settings\Marc\My Documents\testing.mdb"
'This part is the problem as its the apostrophies
what_comp = "'" & frm_invoice.cmb_custname.Text & "'"
Set db = Workspaces(0).OpenDatabase(Path, ReadOnly:=True)
Set qry = db.CreateQueryDef("QRY_custdata")
SQLstring = "SELECT * FROM tbl_customers_data WHERE CUST_NAME = " &
what_comp & ""
qry.Sql = SQLstring
Set rs = qry.OpenRecordset()
Sheets("Sales").Activate
[a2].CopyFromRecordset rs
db.QueryDefs.Delete "QRY_custdata"
db.Close
End sub
The below query works when the string value has no apostriphies e.g
jack wines, however it crashes over when it's Jack's wines.
I had a play about with speech marks and apostrophies and I just can't
get it right. I'm sure theres a quick fix, but i can't see it.
Many thanks in advance,
Marc
Sub get_cust_all()
Path = "D:\Documents and Settings\Marc\My Documents\testing.mdb"
'This part is the problem as its the apostrophies
what_comp = "'" & frm_invoice.cmb_custname.Text & "'"
Set db = Workspaces(0).OpenDatabase(Path, ReadOnly:=True)
Set qry = db.CreateQueryDef("QRY_custdata")
SQLstring = "SELECT * FROM tbl_customers_data WHERE CUST_NAME = " &
what_comp & ""
qry.Sql = SQLstring
Set rs = qry.OpenRecordset()
Sheets("Sales").Activate
[a2].CopyFromRecordset rs
db.QueryDefs.Delete "QRY_custdata"
db.Close
End sub