CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2013
    Posts
    13

    Red face Question about Ado shape

    Hi guys!

    i've some problem with shape, because i didn't understand all the concept yet.

    But, i need to use then... and i've a problem with a situation.

    The problem is about querys that require "agregate function or group by clause". So, i dont know what i need to do, to put a query that require "group by clause" in ado shape without use group by.

    is possible? any idea?

  2. #2
    Join Date
    Aug 2011
    Posts
    35

    Re: Question about Ado shape

    Forget IDE generated code, try using only code. Read and learn to use the controls only code, is the healthiest solution.

  3. #3
    Join Date
    May 2013
    Posts
    13

    Re: Question about Ado shape

    Quote Originally Posted by nexusm View Post
    Forget IDE generated code, try using only code. Read and learn to use the controls only code, is the healthiest solution.
    Thank you :P

    But... to solve my problem, i'll need to use the ado shape command, because i need to fill controls in section7 of my datareport, making groups of information on report.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Question about Ado shape

    Here's an old sample:

    Code:
    Option Explicit
    
    
    Private Sub Command1_Click()
        Dim cnLvConnection As ADODB.Connection
        Set cnLvConnection = New ADODB.Connection
        Dim rsLvRecordset As ADODB.Recordset
        Set rsLvRecordset = New ADODB.Recordset
        With cnLvConnection
            .Provider = "MSDataShape.1"
            .ConnectionString = "Data Source=" & App.Path & "\db1.mdb;" _
                              & "Data Provider=Microsoft.Jet.OLEDB.4.0;"
            .Open
            With rsLvRecordset
                .CursorLocation = adUseClient
                .CursorType = adOpenStatic
                .LockType = adLockReadOnly
            End With
            Set rsLvRecordset = .Execute("SHAPE {SELECT c.CustomerName As Customer, c.CustomerID FROM Customers c ORDER BY c.CustomerName} As Customers" _
                                       & " APPEND ((SHAPE {SELECT oh.OrderNumber As [Order No], oh.CustomerID, oh.OrderHeaderID FROM OrderHeaders oh ORDER BY oh.OrderNumber} As OrderHeaders" _
                                       & "          APPEND ({SELECT od.OrderLine As [Line], od.OrderLineDescription As [Description], od.OrderLineQuantity As Quantity, od.OrderHeaderID FROM OrderDetails od ORDER BY od.OrderLine} As OrderDetails" _
                                       & "          RELATE OrderHeaderID TO OrderHeaderID))" _
                                       & " RELATE CustomerID TO CustomerID)")
        End With
        '   Setup Grid
        Set Me.MSHFlexGrid1.Recordset = rsLvRecordset
        Me.MSHFlexGrid1.ColWidth(1, 0) = 0 ' c.CustomerID
        Me.MSHFlexGrid1.ColWidth(1, 1) = 0 ' oh.CustomerID
        Me.MSHFlexGrid1.ColWidth(2, 1) = 0 ' oh.OrderHeaderID
        Me.MSHFlexGrid1.ColWidth(3, 2) = 0 ' od.OrderHeaderID
        '   Tidy up
        If Not rsLvRecordset Is Nothing Then
            If rsLvRecordset.State <> adStateClosed Then
                rsLvRecordset.Close
            End If
            Set rsLvRecordset = Nothing
        End If
        If Not cnLvConnection Is Nothing Then
            If cnLvConnection.State <> adStateClosed Then
                cnLvConnection.Close
            End If
            Set cnLvConnection = Nothing
        End If
    End Sub
    
    Private Sub Form_Load()
        Me.MSHFlexGrid1.FixedCols = 0
    End Sub
    
    '
    '  Edit the cell, without the update
    
    Private Sub MSHFlexGrid1_KeyPress(KeyAscii As Integer)
       If KeyAscii = vbKeyReturn Then   'enter key
        'move to next cell.
            With MSHFlexGrid1
                If .Col + 1 <= .Cols - 1 Then
                    .Col = .Col + 1
                Else
                    If .Row + 1 <= .Rows - 1 Then
                        .Row = .Row + 1
                        .Col = 0
                    Else
                        .Row = 1
                        .Col = 0
                    End If
                End If
            End With
        ElseIf KeyAscii = vbKeyBack Then   'back space key
            With MSHFlexGrid1
                'back space out the entered characters
                If Len(.Text) Then
                    .Text = Left(.Text, Len(.Text) - 1)
                End If
            End With
        Else
            With MSHFlexGrid1
                .Text = .Text & Chr(KeyAscii)
            End With
        End If
    End Sub


    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    May 2013
    Posts
    13

    Re: Question about Ado shape

    You helped me so much.

    Thank you a lot!

    I'm almost there... i need to solve only one detail.

    My group header, repeat for each line of my report... like a control in section 1 :/

    I was thinking about show the group header again, only when i have different group item.

    Example:


    ---------------------
    Page Header

    Model Description
    --------------------
    Group Header

    Kind
    ---------------

    Result:
    Model Description
    -------------------------------


    Kind: Car

    VX1 A jeep
    VX2 A Buss


    Kind: Computer

    Dell XPS General Use Computer
    Alienware 1 Gamming Computer
    can u understand?

    how can i show the group header, only when i have different kind of data?


    ---------------------------------------------------------------------------------------------------------------




    UPDATED!!!

    Problem Solved, the problem was my function :P

    thank you a lot
    Last edited by rumblefishx; June 12th, 2013 at 11:49 AM.

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured