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: 48
Default Is this Possible




I have a macro that imports data into and access database. Sample
below
Is it possible that during the

.AddNew ' create a new record

line of code to have excel return the autonumber\primary to was
created in access key back to excel. Excel update access row by row
starting column A-L. I want the code to put the primary key in column
j.







Do While Len(Range("A" & r).Formula) 0
' repeat until first empty cell in column A
With rs




..AddNew ' create a new record
' add values to each field in the record
.Fields("DateSubmitted") = Range("A" & r).Value
.Fields("JobNumber") = Range("B" & r).Value
.Fields("JobName") = Range("C" & r).Value
.Fields("TotalPCS") = Range("D" & r).Value
.Fields("Area") = Range("E" & r).Value
.Fields("STREr") = Range("F" & r).Value
.Fields("GTREs") = Range("G" & r).Value
.Fields("Status") = Range("H" & r).Value
.Fields("MailMethod") = Range("I" & r).Value
.Fields("ImportDateTime") = Now()
' add more fields if necessary...
.Update ' stores the new record
End With



r = r + 1 ' next row
Loop
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing







Little Penny




 
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



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