LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to comp.databases.ms-access,microsoft.public.access,microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Excel - Access Table

You can use either DAO or ADO with DSN-less connection in your Excel's VBA
code to send data from the sheets to Jet database (*.mdb). psuedo-code like
this:

Dim cn As ADODB.Connection
Set cn=New ADODB.Connection
cn.Open yourConnectionStringToTheDatabase

''In your loop for each row of the sheet
For each sheetrow of the sheet
cn.Execute "INSERT INTO theTable (Col1, Col2....) VALUES (cell1Value,
cell2Value...)"
Or
cn.Execute "UPDATE theTable SET ....WHERE..."
Next row

cn.Close

Or you can open a RecordSet based a table in the database. Than populate the
RecordSet with data from Excel sheet and do the update the RecordSet back to
the database at the end.

With this kind of approach, you have the full control and the flexibility to
match user selected columns to certain table in the database and do the data
transfer.

"Patonar" wrote in message
ups.com...
Hi,

I would like to be able to using VBA from an Excel macro - go through
each line in my spreadsheet and add to a database.

I know that this can be done via the import external data tool in
access but the final solution i am working towards will allow the user
to select columns from randomly formatted datasets in excel.

I already have code that loops through every row in my excel file to
format it correctly so it isn't the loop i am worried about. It is the
actual insert code from vba i need to use.

Preferably without using a DSN connection if possible and instead
naming the direct route to the database - since this is going to be
stored over the network.

Regards,

Andy



 
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
Access Table into Excel using VB Steve Excel Discussion (Misc queries) 2 February 23rd 09 08:58 PM
Copy Records from Access Database table(more than 5 lakh records in this table) to Excel Sheet divya Excel Programming 1 October 26th 06 12:12 PM
Importing data from Access to Excel, but I need to vary the table from Access Liz L. Excel Programming 3 June 6th 06 02:12 AM
Access table to Excel Tushar[_2_] Excel Programming 6 November 17th 04 08:46 PM
Linking a table in Access to a table in Excel using MS Query Diana[_5_] Excel Programming 1 January 16th 04 09:43 PM


All times are GMT +1. The time now is 07:10 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"