Results 1 to 3 of 3
  1. #1
    JustCallMeAl
    Guest

    Re: bookmark and datagrid

    I have been told to cycle through in a descending manner. So, change the line:

    <pre>For intCount = 0 To intMAX</pre>


    to

    <pre>For intCount = intMax to 0 step -1</pre>


    Don't know if it will help.....

  2. #2
    Kevan
    Guest

    Re: bookmark and datagrid

    thanks al

    My main problem was the record set I was using was adOpenStatic I changed it to adOpenDynamic and inserted a rsdisplay.movenext in after the rsdisplay.Update and it all worked. Then after 3 hours of looking I find the sweet solution on MSDN library.
    in case anybody needs it.
    look up SelBookmarks Property Example in index.

    <pre>Private Sub DeleteRecord()
    Dim varBookmark As Variant

    For Each varBookmark In dgPublisher.SelBookmarks
    rsdisplay.Bookmark = varBookmark
    rsdisplay.Delete
    rsdisplay.MoveFirst
    Next

    End Sub

    </pre>

    how easy was that !!arg

  3. #3
    Kevan
    Guest

    bookmark and datagrid

    hello all

    I am trying to use bookmarks to delete multiple rows in a data grid. the code I have come up with will delete the firs one but a runtime error--->> -2147217885 Row handle referred to a deleted row or a row marked for deletion <<-- happens at the point in the code (marked with bracket). Can anybody point me to a article explaining using bookmarks for multiple deletes or if you have a suggestion.

    <pre>'procedure to delete the records selected by the user
    Private Sub DeleteRecord()

    Dim intCount As Integer
    Dim blnMatch As Boolean ' indicates Match found or
    ' keep looking
    Dim intArrNum() As Variant ' array of selected book marks
    Dim intMAX As Integer ' number of selected items


    intMAX = dgPublisher.SelBookmarks.count - 1

    ' redim array to hold the bookmark numbers
    ' = to the number of bookmarks
    If intMAX < 0 <> True Then
    ReDim intArrNum(intMAX)
    End If

    'place the bookmark numbers in array
    For intCount = 0 To intMAX
    intArrNum(intCount) = dgPublisher.SelBookmarks(intCount)
    Next intCount


    rsdisplay.MoveFirst ' move to start of record set

    If intMAX <> -1 Then ' Make sure some records were selected
    For intCount = 0 To intMAX ' for each selbookmark
    blnMatch = False ' reset match variable

    ' if grid selbookmark and recordset bookmark
    ' have not been matched and record not End of file

    Do While blnMatch <> True
    If rsdisplay.EOF <> True Then
    If rsdisplay.Bookmark = intArrNum(intCount) Then
    ' Match them up (Error here on secon delete)
    rsdisplay.Delete ' delete if they match
    rsdisplay.Update ' update record set
    blnMatch = True ' exit loop
    Else
    rsdisplay.MoveNext ' else Keep looking next record
    End If
    Else
    blnMatch = True ' if end of file exit loop
    End If
    Loop
    Next
    End If

    dgPublisher.Refresh ' refresh grid
    </pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •