Wrox Programmer Forums
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 9th, 2008, 05:10 AM
Authorized User
 
Join Date: Oct 2007
Posts: 46
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via MSN to debbiecoates
Default Datagrid splits

I wondered if anyone could spot anything wrong with this code. i have a datagrid which ib bound to an ADODC control.

I have to datagrid split into two panes with only the totals showing in the right hand lane.

The code works great on another page, but on this page is keeps failing when it gets to the bit that says ' Hide all but the Total column.

I get a memory error, and then the whol application just shuts down. I cant see what is wrong with it since I have used similar code elsewhere.

With DataGrid_ItemisedGrantDetails

    If .Splits.Count = 1 Then ' Append a split.
        .Splits.Add 1
    End If
    .TabAcrossSplits = True


    For i = 0 To 5
        .Splits(0).Columns(i).Width = 1
    Next

    .Splits(0).Columns(6).Width = 3000 'Display
    .Splits(0).Columns(6).Locked = True
    .Splits(0).Columns(7).Width = 300 'CapRev
    .Splits(0).Columns(7).Caption = "" 'CapRev
    .Splits(0).Columns(7).Locked = True

    For i = 8 + fcheckperiods To .Splits(0).Columns.Count - 1
        .Splits(0).Columns(i).Width = 1
    Next

        ' Hide all but the Total column.
        For i = 0 To .Splits(0).Columns.Count - 1
           If .Splits(1).Columns(i).DataField = "Total" Then
              .Splits(1).Columns(i).Visible = True
              Else
              .Splits(1).Columns(i).Visible = False
           End If
        Next i


    .Splits(1).RecordSelectors = False
    .Splits(0).Size = 6000
    .Splits(1).Size = 800
    .Refresh

End With



 
Old September 9th, 2008, 12:00 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Which actual line raises the error?

(I hate errors like this...)

Since this kind of error involve machinery not described in the documentation, changes that would appear to be unrelated sometime can make a difference.
Try eliminating the With block, and being explicit instead.
Try
Code:
        ' Hide all but the Total column.
        For i = 0 To .Splits(0).Columns.Count - 1
           If .Splits(1).Columns(i).DataField = "Total" _
               Then .Splits(1).Columns(i).Visible = True
           If .Splits(1).Columns(i).DataField <> "Total" _
               Then .Splits(1).Columns(i).Visible = False
        Next i
        or
Code:
        ' Hide all but the Total column.
Code:
        For i = 0 To .Splits(0).Columns.Count - 1
           Dim bVis As Boolean
           bVis = .Splits(1).Columns(i).DataField = "Total"
           .Splits(1).Columns(i).Visible = bVis
        Next i
or
Code:
        ' Hide all but the Total column.
        For i = 0 To .Splits(0).Columns.Count - 1
           With .Splits(1).Columns(i)
               .Visible = (.DataField = "Total")
           End With
        Next i
        I mean, all of these “or”s are just ways to try to get the compiled code to behave in some different way, that might skip over the resultant instruction that raises the error condition...





Similar Threads
Thread Thread Starter Forum Replies Last Post
Page splits - Clustered vs Non-Clustered Index carumuga SQL Server 2005 3 October 20th, 2008 04:23 AM
Custom paging in Datagrid with datagrid page count madhusrp ASP.NET 1.0 and 1.1 Professional 12 June 2nd, 2008 01:15 PM
User COntrol Datagrid inside datagrid rodmcleay ASP.NET 1.0 and 1.1 Professional 3 April 14th, 2007 10:11 AM
characters method splits the value of tag ksskumar XSLT 2 January 2nd, 2007 11:15 AM
characters method splits the value of tag ksskumar XML 0 January 2nd, 2007 10:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.