• Error in DBGrid (VB6 SP5; True DBGrid Pro 5.0)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Error in DBGrid (VB6 SP5; True DBGrid Pro 5.0)

    Author
    Topic
    #361980

    Hi,

    I have a form where data is entered for a new client onto DBGrid (using Unbound mode with associated coding from the help). There could be any number of entries on the screen, so I’ve created the grid with 13 blank rows to start off with, which I increment if necessary.

    My big problem is that if a user clicks on the blank part of the grid, I get the error “6148 Invalid Row Number”, in the UnboundWriteData for the grid. If I try to trap that error, and bypass the code, I get other errors firther on. I cannot find anything which stops this error, or which bypasses it. I’ve been told to solve this quickly- any ideas please?

    Private Sub gridSubject_UnboundWriteData( _
    ByVal RowBuf As TrueDBGrid50.RowBuffer, WriteLocation As Variant)
    
    ' The UnboundWriteData event is fired when the user 
    ' modifies an existing row within an unbound grid and
    ' attempts to commit the changes by moving to another
    ' row or calling the Update method of the grid.
    Dim I As Integer
    
    For I = 0 To RowBuf.ColumnCount - 1
      If Not IsNull(RowBuf.Value(0, I)) Then
        If Not StoreUserData(WriteLocation, I, RowBuf.Value(0, I)) Then
          RowBuf.RowCount = 0
          Exit Sub
        End If
      End If
    Next I
    
    End Sub
    Viewing 1 reply thread
    Author
    Replies
    • #548842

      Geoff,

      I have no idea what the DBGrid objects do, but by looking over your code I offer this:

      What is the row number that it thinks is invalid? Is it 0 (zero)?

      Seems to me you’ve got to keep the StoreUserData function from executing if the grid row is blank. Can you test for that?

      • #548992

        Kevin,

        I is zero when this falls over- but the row number is the rownumber of the RowBuf object. I don’t have a good handle on how that all fits in- it’s just really messy stuff- all code which was provided with the control, but really really hard to figure out.

        I will try testing for a blank row- but It does seem that there’s something in the StoreUserData which is vital to the processing later on.

        Thanks for the input.

    • #548916

      Geoff,

      Is that the Apex control? I haven’t used it and don’t have the documentation for it, but If the SelChange event occurs when a row or column is deselected, could you use that to trap the problem before it gets to the UnboundWriteData event?

      • #548991

        Charlotte,

        Yes, that is the Apex control.

        Thanks for the thought- but the UnboundWriteData occurs before the selChange. I think it’s triggred by the grid Update event- which pushes data from the grid into an internal array which holds a copy of all the data.

        The code which came with the control is very messy. If I’d had my druthers, I would have done it all a different way. Too late now.

        The code which gets executed in StoreUserData, which is called from this event, seems vital. If I bypass the UnboundWrite stuff, and don’t execute what’;s in SToreUserData, I get errors later on.

        Thanks for the input.

    Viewing 1 reply thread
    Reply To: Error in DBGrid (VB6 SP5; True DBGrid Pro 5.0)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: