Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Data from excel to MS Access

I have an excell sheet that we use to order a product. I would like to put a
button the sheet that runs code that will 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 (also used as
out job number) and send that number to a cell on the excel sheet.
Any one care to help me with this code?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default Data from excel to MS Access


"JCanyoneer" wrote in message
...
I have an excell sheet that we use to order a product. I would like to put

a
button the sheet that runs code that will 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 (also used

as
out job number) and send that number to a cell on the excel sheet.
Any one care to help me with this code?


You can use ADO from a macro. Here's some sample code
http://www.exceltip.com/st/Import_da...Excel/427.html

/Fredrik



  #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.

--

Reply
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 10:03 PM.

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"