Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Excel to Access using ASP

Hi
Anyone know an ASP script for transferring data from an Excel sheet to an
Access table, some of the fields of which contain names which have an
apostrophe (') in them.
I have tried all sorts of things but am getting tripped up by the apostrophe
which is used as a field container in the SQL :

"INSERT INTO tblResults Values(0,'" & rsExcel("FeisID") & "' , '" &
rsExcel("CompNo") & "' , '" & rsExcel("Entry") & "' , '" & rsExcel("Name") &
"' , '" & rsExcel("School") & "' , '" & rsExcel("Position") & "' , '0' , '"
& Done & "')"

The first field is the ID field of tblResults and need to be incremented
automatically. If I leave the first value out, I get an error along the
lines of "Number of query values and destination fields are not the same"
Also, if the name field is like Harry O'Hare, the thing fails...
Any ideas anyone? Many thanks

Jim


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Excel to Access using ASP

Use replace(strValue,"'","''") to deal with the apostrophe problem.

Also, if the first field increments automatically, you should remove it from
both the Fields and the Values parameters.

Regards,
Wayne C.,

"Jim" wrote in message
...
Hi
Anyone know an ASP script for transferring data from an Excel sheet to an
Access table, some of the fields of which contain names which have an
apostrophe (') in them.
I have tried all sorts of things but am getting tripped up by the
apostrophe which is used as a field container in the SQL :

"INSERT INTO tblResults Values(0,'" & rsExcel("FeisID") & "' , '" &
rsExcel("CompNo") & "' , '" & rsExcel("Entry") & "' , '" & rsExcel("Name")
& "' , '" & rsExcel("School") & "' , '" & rsExcel("Position") & "' , '0' ,
'" & Done & "')"

The first field is the ID field of tblResults and need to be incremented
automatically. If I leave the first value out, I get an error along the
lines of "Number of query values and destination fields are not the same"
Also, if the name field is like Harry O'Hare, the thing fails...
Any ideas anyone? Many thanks

Jim



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Excel to Access using ASP


Jim wrote:
Anyone know an ASP script for transferring data from an Excel sheet

to an
Access table, some of the fields of which contain names which have an


apostrophe (') in them.

"INSERT INTO tblResults Values(0,'" & rsExcel("FeisID") & "' , '" &
rsExcel("CompNo") & "' , '" & rsExcel("Entry") & "' , '" &

rsExcel("Name") &
"' , '" & rsExcel("School") & "' , '" & rsExcel("Position") & "' ,

'0' , '"
& Done & "')"


You may not need the recordset e.g. something like this:

INSERT INTO
FeisID, CompNo,
Entry, Name, School,
[Position], text_col, Done
SELECT
FeisID, CompNo,
Entry, Name, School,
[Position], '0' Done
FROM
[Excel 8.0;Database=C:\MyBook.xls;].[MySheet$];

Jamie.

--

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query from Access into Excel cause Access to go to read only T Stephens Excel Discussion (Misc queries) 0 March 24th 09 04:17 PM
Can Excel access data from Access?! Al Excel Discussion (Misc queries) 5 April 5th 08 03:52 PM
export access to excel. change access & update excel at same time fastcar Excel Discussion (Misc queries) 0 June 24th 05 09:27 PM
Access data -work in Excel- save in Access s_u_resh Excel Programming 1 October 25th 04 12:52 PM
Getting Access Error Messages when running Access through Excel Dkline[_2_] Excel Programming 0 October 12th 04 09:35 PM


All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"