 |
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: INSERT - Dynamic values Archived to Disk
You mean like the following?
db.Execute "INSERT INTO [tbl] (name) VALUES (" & rst.Fields![name].Value & ");"
|
|
17-07-2002 at 05:23 AM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: INSERT - Dynamic values Archived to Disk
The line has to be in a module, not in the query itself.
|
|
17-07-2002 at 11:29 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: INSERT - Dynamic values Archived to Disk
There are other characters that cause problems too sometimes, although I don't remember which ones offhand, but you just double them also.
str = 'Field string to insert
str = replace(str,"'","''")
str = replace(str,chr(34),chr(34) & chr(34))
' Or in one line, given str is the string to insert:
... VALUES ('" replace(replace(str,"'","''"),chr(34), chr(34) & chr(34)) & "')"
Of course if it's done in a module or code, you could open recordsets for the data (origin and destination) and not have to worry about the special characters.
[Edited by JLRodgers on 18-07-2002 at 12:45 PM GMT]
|
|
18-07-2002 at 06:40 PM |
|
|
nuttallm Level: Guest

|
SQL 'Replace' Archived to Disk
Need help...I can't seem to get Replace (syntax) to work. I want SQL to insert fields to table (and ignore/replace any special characters like the ' ).
db.Execute "INSERT INTO [tbl Exceptions Table] (SWLIN, GCMA, HULL, DEFICIENCY, CORR_BY, CORR_PER, STATUS, DESCRIPT) VALUES " _
& "('" & rst.Fields![SWLIN].Value & "', '" & rst.Fields![GCMA].Value & "', '" & rst.Fields![HULL].Value & "'," _
& " '" & rst.Fields![DEFICIENCY].Value & "', '" & rst.Fields![CORR_BY].Value & "', '" & rst.Fields![CORR_PER].Value & "', " _
& " '" & rst.Fields![STATUS].Value & "', '" & Replace (rst.Fields![DESCRIPT].Value, " '", "''"));"
[Edited by admin on 19-07-2002 at 04:36 PM GMT]
|
|
19-07-2002 at 01:33 PM |
|
|  |
|
|
|
|
 |
 |