Re: Newbie ADODB.Recordset MoveNext problem

From: Val Mazur \(MVP\) (group51a_at_hotmail.com)
Date: 03/18/05


Date: Thu, 17 Mar 2005 20:58:47 -0500

Hi,

What kind of error do you get? See if it helps

http://support.microsoft.com/default.aspx?scid=kb;en-us;286153

-- 
Val Mazur
Microsoft MVP
http://xport.mvps.org
"f3773t" <f3773t@discussions.microsoft.com> wrote in message 
news:1D9D5FC2-D7E8-4DCC-8013-A3CE680B4EF9@microsoft.com...
>I have the following function shown below:
> Now the code executes fine for record sets smaller than MAXLOCKSPERFILE
> in the system registry.
> However as soon as the record set is larger than MAXLOCKSPERFILE in the
> system registry an error occurs.
>
> This leads me to think that somewhere in the function shown below, within
> the while loop a lock is being placed on the database file.
> How do I fix this problem?
>
> Thanks very much!!
>
> Public Function RemoveOrientationAMPM(aRs As ADODB.Recordset) As Boolean
>  Dim sOrientation As String
>
>  ' Check if the Orientation field exists in the recordset
>  If FieldExists("Orientation", aRs) Then
>    With aRs
>      If .RecordCount > 0 Then
>        .MoveFirst  ' Move to the first record
>
>        ' While there are still records
>        Do While Not .EOF
>          ' Get the string value from the database
>          sOrientation = .Fields("Orientation").Value
>
>          ' Remove the AM if it exists
>          sOrientation = Left(sOrientation, IIf(InStr(sOrientation, "A") >
> 0, InStr(sOrientation, "AM") - 1, Len(sOrientation)))
>
>          ' Remove the PM if it exists
>          sOrientation = Left(sOrientation, IIf(InStr(sOrientation, "P") >
> 0, InStr(sOrientation, "PM") - 1, Len(sOrientation)))
>
>          ' Write the modified value back into the field
>          .Fields("Orientation").Value = Trim(sOrientation)
>
>          ' Get the next record
>          .MoveNext
>        Loop
>      End If
>    End With
>  End If
>
>  RemoveOrientationAMPM = True
>
>  Exit Function
>
> ErrorHandler:
>  MsgBox Err.Number & " " & Err.Description
>  RemoveOrientationAMPM = False
> End Function