-
June 11th, 2013, 06:17 AM
#1
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?
-
June 11th, 2013, 08:47 AM
#2
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.
-
June 11th, 2013, 10:49 AM
#3
Re: Question about Ado shape
 Originally Posted by nexusm
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.
-
June 11th, 2013, 12:18 PM
#4
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
-
June 12th, 2013, 09:13 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|