Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
exporting to excel | Excel Discussion (Misc queries) | |||
exporting from Excel | Excel Discussion (Misc queries) | |||
exporting to excel | Excel Discussion (Misc queries) | |||
Exporting into Excel | Excel Discussion (Misc queries) | |||
Exporting to Excel | Excel Programming |