I am trying to move some of my queries into code to try to make my db a bit more compact and manageable but I am having difficulties.
This is the code I have put in (the connection and recordset are all dimensioned and set earlier)
I am trying here to flag a field in each record when the patient (lngPtId) occurs more than once in the table.
___________________________
rst.Open "tblTmpDispLab", cnn, adOpenDynamic, adLockOptimistic
With rst
.MoveLast
.MoveFirst
Do While Not .EOF
If DCount("lngPtId", "tblTmpDispLab") > 1 Then
.Fields("bDispMult") = Yes
.Update
End If
.MoveNext
Loop
______________________________
It falls over on the .Fields("bDispMult") = Yes line.
Is it that I am trying to run a DCount off the recordset I am working with (if so does that mean working with a recordset clone which I have heard of but never used), or do I need to somehow define my DCount differently?
Any help very much appreciated
Thanks
Malcy
This is the code I have put in (the connection and recordset are all dimensioned and set earlier)
I am trying here to flag a field in each record when the patient (lngPtId) occurs more than once in the table.
___________________________
rst.Open "tblTmpDispLab", cnn, adOpenDynamic, adLockOptimistic
With rst
.MoveLast
.MoveFirst
Do While Not .EOF
If DCount("lngPtId", "tblTmpDispLab") > 1 Then
.Fields("bDispMult") = Yes
.Update
End If
.MoveNext
Loop
______________________________
It falls over on the .Fields("bDispMult") = Yes line.
Is it that I am trying to run a DCount off the recordset I am working with (if so does that mean working with a recordset clone which I have heard of but never used), or do I need to somehow define my DCount differently?
Any help very much appreciated
Thanks
Malcy