Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Recordset pointer changing position when checkbox set

I am using ADO in a VB6 application connecting to an Access 2000 database. When I am updating a form with record data, the recordset pointer will move from the current record to the first record when I try to update a checkbox in the form. If I comment out the checkbox code the recordset pointer stays put. I am certain I am not trying to set the checkbox with a -1 value.
Is this an ADO bug or do I need to figure out a way to copy just the record I want into a new recordset before I update the form?

Thanks in advance,
jaked6803

Comments

  • jaked6803jaked6803 Member Posts: 3
    : I am using ADO in a VB6 application connecting to an Access 2000 database. When I am updating a form with record data, the recordset pointer will move from the current record to the first record when I try to update a checkbox in the form. If I comment out the checkbox code the recordset pointer stays put. I am certain I am not trying to set the checkbox with a -1 value.
    : Is this an ADO bug or do I need to figure out a way to copy just the record I want into a new recordset before I update the form?
    :
    : Thanks in advance,
    : jaked6803
    :

    I made my own workaround for the problem. So this is FYI for anyone else.
    I get the recordset and I use Find to locate the record I want. Then I use Clone to get a copy of the recordset so I don't change the original. Since I found what I'm looking for, I use Filter on the cloned recordset with the same criteria I used in Find to get the one record I want. Then I return the Fields object for use with my display function.

    Public Function GetRecord(ByVal strDataset As String, ByRef oRecord As ADODB.Fields, ByVal strField as String, ByVal strID as string) As String
    On Error Goto GetRecordErr

    Dim oRecordset as ADODB.Recordset
    Dim oClone as ADODB.Recordset
    Dim strErr as String

    'Initialize the return value
    GetRecord = ""

    'This is my own function that gets the recordset I want from a collection so I have the recordset I need

    GetRecord = GetRecordset(strDataset, oRecordset)
    If GetRecord <> "" then Exit Function

    oRecordset.Find strField & "=" & strID
    If oRecordset.EOF then
    GetRecord = "Record not found!"
    Exit Function
    End If

    'create a clone so the original recordset isn't changed by the filter
    Set oClone = oRecordset.Clone
    oClone.Filter strField & "=" & strID

    Set oRecord = oClone.Fields
    Cleanup:
    Set oRecordset = Nothing
    Set oClone = Nothing
    Exit Function
    GetRecordErr:
    GetRecord = "GetRecord Error: " & Err.Description
    On Error Goto 0
    Goto Cleanup
    End Function

Sign In or Register to comment.