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: 13
Default Export Data to Access Table

Afternoon, I have an Excel Spreedsheet which is used throughout the
Office to track assignments given to each staff member. I am now
wanting to add a worksheet which will track staff contacts and upload
that information to a Center Database. I wrote the following code to
check for records already in the Database and update them -if
necessary, And also to add new records as needed. But I continue to
have Loop problems, and suggestions... Thanks

Sub DatabaseTransfer()
'
'
Dim dbs As Database
Dim rs As Recordset
Dim adjlog As String
Dim notfound As Boolean

adjlog = "\\xxxx.mdb"
Set dbs = OpenDatabase(adjlog)
Set rs = dbs.OpenRecordset("TEntry", dbOpenTable)
notfound = True
For R = 4 To 300
ColE = ActiveDocument.Cells(R, 5).Value
If ColE = "" Then
Exit For
End If
Do While Not rs.EOF
If ActiveDocument.Cells(1, 5).Value = rs.Fields("Login") _
And ActiveDocument.Cells(R, 5).Value = rs.Fields("SSN") Then
rs.Edit
rs.Fields("Login") = Range("F" & 1).Value 'Login is static
rs.Fields("From") = ActiveDocument.Cells(R, 3).Value
rs.Fields("Type") = ActiveDocument.Cells(R, 4).Value
rs.Fields("Date/Time") = ActiveDocument.Cells(R, 2).Value
rs.Fields("SSN") = ActiveDocument.Cells(R, 5).Value
rs.Fields("Claimant") = ActiveDocument.Cells(R, 6).Value
rs.Fields("OthPhone") = ActiveDocument.Cells(R, 7).Value
rs.Fields("Employer") = ActiveDocument.Cells(R, 9).Value
rs.Fields("Contact") = ActiveDocument.Cells(R, 10).Value
rs.Fields("OthEPhone") = ActiveDocument.Cells(R, 11).Value
rs.Fields("Action") = ActiveDocument.Cells(R, 12).Value
rs.Fields("Remarks") = ActiveDocument.Cells(R, 13).Value
rs.Update
notfound = False
Exit Do
Loop
Next
Else
rs.MoveNext
rs.AddNew
rs.Fields("Login") = Range("F" & 1).Value
rs.Fields("From") = ActiveDocument.Cells(R, 3).Value
rs.Fields("Type") = ActiveDocument.Cells(R, 4).Value
rs.Fields("Date/Time") = ActiveDocument.Cells(R, 2).Value
rs.Fields("SSN") = ActiveDocument.Cells(R, 5).Value
rs.Fields("Claimant") = ActiveDocument.Cells(R, 6).Value
rs.Fields("OthPhone") = ActiveDocument.Cells(R, 7).Value
rs.Fields("Employer") = ActiveDocument.Cells(R, 9).Value
rs.Fields("Contact") = ActiveDocument.Cells(R, 10).Value
rs.Fields("OthEPhone") = ActiveDocument.Cells(R, 11).Value
rs.Fields("Action") = ActiveDocument.Cells(R, 12).Value
rs.Fields("Remarks") = ActiveDocument.Cells(R, 13).Value
Dim response As Variant
response = MsgBox("New Record Added to AdjLog Record")
rs.Update
End If
rs.Close
Set rs = Nothing
dbs.Close
Set dbs = Nothing

End Sub
 
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
Export Single Record to Append to Access Table RMS Excel Discussion (Misc queries) 1 December 9th 08 07:08 PM
Data Export from Access to Excel Teresa NS Excel Discussion (Misc queries) 2 December 2nd 08 06:46 PM
excel worksheet export into access table H. Chudhary Excel Worksheet Functions 0 January 23rd 08 02:26 PM
Can you export a pivot table into Access? Tracy Excel Discussion (Misc queries) 3 June 27th 07 12:41 AM
Is there any way to export a .xls table to Access .mdb without Acc Mr. Analogy Excel Discussion (Misc queries) 0 February 1st 07 12:05 AM


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