Hi guys,
I am trying to do this:
If the ResultLetter field is No, then append the Memo field and change ResultLetter to Yes, otherwise go to the next record in the table.
But the code below is doing this:
If the ResultLetter field is No, then append the Memo field and don't worry about changing ResultLetter to Yes, then ignore all following records, because I'm lazy, useless and had a massive weekend - I'll work when I want to.
#Note - Access has no sense of humour, the added comedy was to stop me from tearing my hair out.
Any clues as to what I muffed up?
I am trying to do this:
If the ResultLetter field is No, then append the Memo field and change ResultLetter to Yes, otherwise go to the next record in the table.
But the code below is doing this:
If the ResultLetter field is No, then append the Memo field and don't worry about changing ResultLetter to Yes, then ignore all following records, because I'm lazy, useless and had a massive weekend - I'll work when I want to.
#Note - Access has no sense of humour, the added comedy was to stop me from tearing my hair out.

Code:
Private Sub TickAllButton_Click()
On Error GoTo Err_ClearAllButton_Click
Dim dbs As Database
Dim rst As Recordset
Dim Counter As Integer
Dim objNetwork
Set objNetwork = CreateObject("WScript.Network")
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Select * FROM Practitioner", dbOpenDynaset)
Counter = rst.RecordCount
While Counter > 0
With rst
If .Fields("ResultLetter") = No Then
.Edit
.Fields("Memo") = .Fields("Memo").Value & vbCrLf & "Result letter sent on " & Now() & " by " & objNetwork.UserName
.Fields("ResultLetter") = Yes
.Update
End If
End With
rst.MoveNext
Counter = Counter - 1
Wend
rst.Close
dbs.Close
'Dim stDocName As String
'stDocName = "TickAllRecords"
'DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_ClearAllButton_Click:
Exit Sub
Err_ClearAllButton_Click:
MsgBox Err.Description
Resume Exit_ClearAllButton_Click
End Sub
Any clues as to what I muffed up?