|
-
Oct 11th, 2001, 01:48 AM
#1
Thread Starter
Junior Member
transfer data from excel to access using coding..
-
Oct 11th, 2001, 02:55 AM
#2
Hyperactive Member
run a loop in excel that passes the data into a multi-dimension array.
then insert the data into Access using sql
hope this helps
"...They even have the internet on computers..." :- Homer Simpson
"Second Place is First Looser" :- No Fear
-
Oct 11th, 2001, 02:58 AM
#3
Thread Starter
Junior Member
Originally posted by beasty1711
run a loop in excel that passes the data into a multi-dimension array.
then insert the data into Access using sql
hope this helps
i c star heee got any examples?
-
Oct 11th, 2001, 03:10 AM
#4
Junior Member
dim objexcel as new excel.application
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open ("c:\temp.xls")
With objExcel.Worksheets(1)
For r = 1 To .UsedRange.Rows.Count
name = .Cells(r, 1).Value
address = .cells(r,2).value
xsql = "INSERT INTO table1 VALUES ('" & name & "','" &
address & "')"
adodb.execute xsql
next
note : adodb is your database connection
-
Oct 11th, 2001, 08:46 PM
#5
Thread Starter
Junior Member
Originally posted by tpiano
dim objexcel as new excel.application
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open ("c:\temp.xls")
With objExcel.Worksheets(1)
For r = 1 To .UsedRange.Rows.Count
name = .Cells(r, 1).Value
address = .cells(r,2).value
xsql = "INSERT INTO table1 VALUES ('" & name & "','" &
address & "')"
adodb.execute xsql
next
note : adodb is your database connection
wat if i dont know the columns name at the first place or i dont know how many columns are there
-
Oct 11th, 2001, 09:56 PM
#6
Junior Member
with this approach it is assume the corresponding col. to take matching with your table columns. with the number of columns you can determine by usedrange.cols.count.
another simpler approached is to link the excel files in your database either in design time or in runtime..
i can help you more if you clarify further what your requirement is ?
-
Oct 11th, 2001, 10:02 PM
#7
Thread Starter
Junior Member
Originally posted by tpiano
with this approach it is assume the corresponding col. to take matching with your table columns. with the number of columns you can determine by usedrange.cols.count.
another simpler approached is to link the excel files in your database either in design time or in runtime..
i can help you more if you clarify further what your requirement is ?
i need to create a table in access and transfer my data in my worksheets over in this case i have about 8 columns to transfer from my worksheets and i need 2 columns to be defaulted to 0 which means i have 10 columns all in all. one more thing i realise when i run this coding it does transfer but the excel application appear to be still running in the background. is it my system problem or?..
-
Oct 11th, 2001, 10:41 PM
#8
Junior Member
add this lines to close the excel application in the background
objexcel.activeworkbook.close
set objexcel = nothing
-
Oct 12th, 2001, 02:54 AM
#9
Thread Starter
Junior Member
shucks.. how do i link to the database using ADO
in DAO
set db = opendatabase("c:\test.mdb")
sql = "select * from test table"
set rs= db.openrecordset(sql,dbopendynaset)
text1.text = rs!name
erm how do we code using ADO?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|