View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Little Penny[_3_] Little Penny[_3_] is offline
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