LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Do---Loop Error in Complex Code

Hi Pete,
You seem to have your loop tangled up with your if..then and your
for..next. Is this what you mean? (I removed some of the goo to make
it easier to see what is going on)
regards
Paul

Sub DatabaseTransfer()
'
'
Dim dbs As Database
Dim rs As Recordset
Dim adjlog As String
Dim notfound As Boolean
Dim response As Variant
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
With rs
Do While Not .EOF
If ActiveDocument.Cells(1, 5).Value = .Fields("Login") _
And ActiveDocument.Cells(R, 5).Value = .Fields("SSN") Then
.Edit
.Fields("Login") = Range("F" & 1).Value 'Login is static
'and the rest
.Update
notfound = False
Exit Do
Else
.MoveNext
.AddNew
.Fields("Login") = Range("F" & 1).Value
'and the rest
response = MsgBox("New Record Added to AdjLog Record")
.Update
End If
Loop
End with
next R
rs.Close
End with
Set rs = Nothing
dbs.Close
Set dbs = Nothing

End Sub

(Pete T) wrote in message . com...
Evening, 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 (Table aready exist). 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...



 
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
Loop or Find code ?? need help !! EBnLP01 Excel Worksheet Functions 4 October 29th 09 05:47 PM
loop code error help!!!! cesaoes Excel Discussion (Misc queries) 2 January 29th 08 04:52 PM
Loop for VBA code? paulinoluciano Excel Worksheet Functions 5 December 28th 05 01:30 PM
How to Loop some code Phil Osman Excel Discussion (Misc queries) 2 August 19th 05 11:14 AM
VB for excel, how do I loop through code steve hobden via OfficeKB.com Excel Discussion (Misc queries) 2 June 9th 05 01:59 PM


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