LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default ole link from excel to access

I have an excel spreadsheet that currently will run a macro (when a button is
clicked) which will open an access file, create a new record in a certain
table, and fill in certain fields. I have added an OLE field to the table
which I would like to be linked to the excell file. I have figured out how to
do this from access, manually for each record, but would like the macro in
excel to do this automatically when it is filling in the other fields. Can
anyone help me with the code for this? Here is the current code I have for
doing what I have described without the OLE part:

Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & "Data
Source=S:\Time Clock\NJC.mdb"
' open a recordset
Set rs = New ADODB.Recordset
rs.Open "Jobs", cn, adOpenKeyset, adLockOptimistic, adCmdTable
' all records in a table
With rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("Date") = Now()
.Fields("Company") = Range("D4")
If Range("E2") 10000 Then
.Fields("Description") = "Accessories for APS Pickup
veh# " & Range("E2").Value & "."
Else
.Fields("Description") = "Accessories for APS Pickup
veh# 0" & Range("E2").Value & "."
End If
.Fields("HourlyCost") = 54
.Fields("HourlyPrice") = 72
.Fields("Status") = "C"
.Fields("EstimateTot") = Range("F25").Value
' add more fields if necessary...
.Update ' stores the new record
End With
Range("E1").Value = rs.Fields("JobNumber")
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
 
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
Link Excel To Access James Excel Discussion (Misc queries) 3 August 24th 09 06:08 PM
Excel and Access link rook Links and Linking in Excel 2 September 21st 06 04:16 AM
Link Excel to Access Jerid B Excel Discussion (Misc queries) 3 August 28th 06 08:03 PM
Access link "add in" for excel MOM4ME Excel Worksheet Functions 4 May 25th 05 01:41 AM
excel link to access Marcus Maginniss Excel Programming 2 August 1st 03 09:10 AM


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