LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Data from excel to MS Access


Fredrik Wahlgren wrote:
make a new record in an existing
table in a certain Access database. Some of the info will be from

the
cells
on the sheet and some will be standard text like "accessories for

vehicle"
&
range("a1") & "from XYZ company".
The existing database has a table called "Jobs" that this info will

go
into.
I want the code to select the very next autonumber/primary key
and send that number to a cell on the excel sheet.


You can use ADO from a macro. Here's some sample code
Import_data_from_Access_to_Excel_(ADO)_using_VBA_i n_Microsoft_Excel


The OP wants to *export*:

Sub TestExport()
Dim Con As Object
Dim rs As Object
Set Con = CreateObject("ADODB.Connection")
With Con
.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\MyJetDB.mdb"
.Open
.Execute _
"INSERT INTO Jobs (data_col) VALUES('" & _
"accessories for vehicle" & Range("A1").Value & _
"from XYZ company" & _
"');"
Set rs = .Execute( _
"SELECT @@IDENTITY")
Range("B1").CopyFromRecordset rs
End With
End Sub

Jamie.

--

 
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
Can Excel access data from Access?! Al Excel Discussion (Misc queries) 5 April 5th 08 03:52 PM
best way to get data from Access to Excel? deko[_2_] Excel Programming 4 February 27th 05 12:25 AM
Access data -work in Excel- save in Access s_u_resh Excel Programming 1 October 25th 04 12:52 PM
Data from Access to Excel FPA Excel Programming 0 May 18th 04 06:44 PM
Excel data to Access newbie[_2_] Excel Programming 2 July 11th 03 03:04 PM


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