LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default exporting to excel

I found this code that will copy the data from excel and export it to a
database that i created. Unfor, it only takes goes rows. So when i hit the
upload button, it only takes the firs row. I am wondering if anyone can help
me out to make it loop until last record
I tried the loop command but it was coming back as error. Please help. thanks

code:
Dim MyCn As ADODB.Connection
Dim SQLStr As String

Set MyCn = New ADODB.Connection

MyCn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & _
"DBQ=F:\System Analyst\Logistics\Logistics CDI.mdb" ' Replace actual
Access file path here
' Note: If database has userID and password, need to specify them here also
' by appending "; UID=MyUserID; PWD=MyPassword"
' - if trouble accessing the file do a net search for help on Connection
Strings

SQLStr = "INSERT INTO [test] " _
& "Values ('" & Range("A12").Value & "', '" & Range("B12").Value & "',
'" _
& Range("C12").Value & "', '" & Range("D12").Value & "', '" &
Range("E12").Value & "', '" _
& Range("F12").Value & "', '" & Range("G12").Value & "', '" &
Range("H12").Value & "', '" _
& Range("I12").Value & "', '" & Range("J12").Value & "', '" &
Range("K12").Value & "', '" _
& Range("L12").Value & "', '" & Range("M12").Value & "', '" &
Range("N12").Value & "')"
' NOTE: The above assumes all fields are TEXT data type, that is why
the "'"s;
' might have trouble with other data types unless you match the format
expected
' by the database

MyCn.Execute SQLStr

MsgBox "Data has been uploaded to CDI ERROR DATA"
MyCn.Close
Set MyCn = Nothing


End Sub
 
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
exporting to excel camri6 Excel Discussion (Misc queries) 3 December 4th 08 08:30 AM
exporting from Excel PAG Excel Discussion (Misc queries) 2 November 12th 07 02:54 PM
exporting to excel boba Excel Discussion (Misc queries) 0 July 23rd 07 03:46 AM
Exporting into Excel Chey Excel Discussion (Misc queries) 2 October 3rd 06 03:39 PM
Exporting to Excel Tater Excel Programming 3 August 29th 05 11:59 PM


All times are GMT +1. The time now is 06:13 AM.

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"