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

How to retrieve fields with an accent (') inside from a mdb

Status
Not open for further replies.

gmeg1

IS-IT--Management
Oct 2, 2002
14
0
0
IT
Hy, I'm new to vbs,
I have an access database and I need to filter the fields in a table based on the value returned from another table. My problem is that some of the records in the first table contain the ' carachter. So when I filter the 2nd table based on the variable returned from the 1st table in the variable there is the ' carachter. For example in my main table the field pcname has: "pc-001" on the first record, "pc-prt" on the second and "pc-4'f" in the third (text field).
When I do a cycle to scan all the database for filtering the 2nd table I use a procedure like:
'(adotable1 is the recordset containing the record fof the 1st table)
'(adotable2 is the recordset containing the 2nd table that I want filter based on the field pcname from the first table)
' (both tha tables have a field named pcname)

adotable1.movefirst
do while not adotable1.eof

strfilter= " pcname='" & adotable1("pcname") & "'"
adotable2.filter strfilter
' here there are more commands to manage the table2 records filtered....
'then I do the same commands on the next record of the table 1

loop

It works for all the records of adotable1 that do not have the ' sign in it. But when it reach the 3rd record it generates an error, because the strfilter variable has the value of:

strfilter = "pcname='pc-4'f' and the ' inside creates the error.

Can someone tell me how can I manage this situation?

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top