23. december 2003 - 13:24Der er
10 kommentarer og 1 løsning
AccXP:Subdatasheets vist i en formular ?
jeg har i mange år brugt datarkvisning af et søgeresultat. Da jeg nu har et søgeresultat, som giver op til flere resultater med samme ID, ville jeg gerne blot vise hovedresultat som en resultatlinie og alle relaterede resultater som subdatasheet.
Jeg har lavet Queryen som flot viser hovedresultatet og valgte subdatasheet, men
Dataarkvisningen i formularen kan tilsyneladende ikke håndtere hierakiske data.
Findes der en ren Access løsning, eller skal jeg over i at installere en 'hierarchical flexgrid control' og lave min Query om efter:
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
There isnt a pure Access solution for this and I Office developer doesnt contain this component. There are a couple of grids on the market which are compatible with Access an damny which are not.
The VSFlexgrid (videosoft) works great with Access. I am not sure if this is th esame flexgrid which comes with MS Visual Basic.
HM - skulle der mon ikke være en felxgrid i Office XP developer ? Fandt denne artikel: 'Displaying a Hierarchical FlexGrid on an Access Form - Microsoft Office 2000 Developer'
Henrik, I have now found the flexgrid but I am still not sure if it comes with XP Developer or something else. I'll try and find out for sure if it does come with XP developer and get back.
The printed manual is terrible and I cant find any mention of these extra controls. This is taken from XP Developer Online Documentation!
Microsoft Office XP Developer Reference
ModHFGrid ControlSee Also Properties, Methods, and Events | Calling a Stored Procedure | Issue Tracking Team Solution | ModHFGrid Error Constants | Stored Procedures The Microsoft® Office XP Developer Hierarchical FlexGrid (ModHFGrid) control displays and operates on tabular data. It makes possible complete flexibility to sort, merge, and format tables containing strings and pictures. When bound to a data control, ModHFGrid displays read-only data.
Syntax
ModHFGrid Remarks
You can place text, a picture, or both in any cell of a ModHFGrid. The Row and Col properties specify the current cell in a ModHFGrid. You can specify the current cell using code, or the user can change it at run time using the mouse or the arrow keys. The Text property references the contents of the current cell.
If the text in a cell is too long to display in the cell and the WordWrap property is set to True, the text wraps to the next line within the same cell. To display the wrapped text, you might be required to increase the cell's column width (ColWidth property) or row height (RowHeight property).
Use the Col and Row properties to determine the number of columns and rows in a ModHFGrid. Use the Band properties to determine the band styles in ModHFGrid.
Displaying Hierarchical Recordsets A major feature of the ModHFGrid control is its ability to display hierarchical recordsets — relational tables displayed in a hierarchical fashion. The easiest way to create a hierarchical recordset is to use the Data Environment designer and assign the DataSource property of the ModHFGrid control to the Data Environment. In addition, you can create a hierarchical recordset in code using a Shape command as the RecordSource for an ADO Data Control, as shown in the following example:
' Create a ConnectionString. Dim strCn As String strCn = "Provider=MSDataShape.1;Data Source=Nwind;" & _ "Connect Timeout=15;Data Provider=MSDASQL"
' Create a Shape command. Dim strSh As String strSh = "SHAPE {SELECT * FROM `Customers`} AS Customers " & _ "APPEND ({SELECT * FROM `Orders`} AS Orders RELATE " & _ "CustomerID TO CustomerID) AS Orders"
' Assign the ConnectionString to an ADO Data Control's ' ConnectionString property, and the Shape command to the ' control's RecordSource property. With Adodc1 .ConnectionString = strCn .RecordSource = strSh End With ' Set the HflexGrid control's DataSource property to the ' ADO Data control. Set HFlexGrid1.DataSource = Adodc1
Yep found it too and had it up and working - look at my lousy code behind form ( time for x-mas holiday) - some formatting of the grid display is mandatory:
Option Compare Database Option Explicit
Sub test() Dim adoxCat As Catalog 'Set a reference for Microsoft ADO Ext. 2.1 (2.7) 'for DDL and security. Dim cboStr As String, Cancel As Integer Dim objT As Table, objV As Object Dim cnn As ADODB.Connection Set cnn = CurrentProject.Connection Set adoxCat = New ADOX.Catalog
adoxCat.ActiveConnection = cnn
cboStr = "Table/View Name;Type;"
For Each objT In adoxCat.Tables If Left(objT.Name, 4) = "mSys" Or _ Left(objT.Name, 1) = "~" Then GoTo NotATable End If
' Before adding the table to the ComboBox string, make ' sure the table isn't a view as we'll add these later. If objT.Type <> "VIEW" Then cboStr = cboStr & objT.Name & ";table;" End If
NotATable: Next objT
'Loop through the views to add the queries. For Each objV In adoxCat.Views cboStr = cboStr & objV.Name & ";View;" Next objV
cboT_V.RowSource = cboStr 'MsgBox cboStr End Sub
Private Sub Form_Load() test End Sub
Sub test2() Dim topSource As String, subSourceType As String, sourceType As String, subds As String Dim LinkCF As String, LinkMF As String, a As String Dim rst As ADODB.Recordset, strConnect As String, sqlstr As String
topSource = Me!cboT_V If InStr(topSource, " ") Then topSource = "[" & topSource & "]" End If
sourceType = Me!cboT_V.Column(1)
If sourceType = "Table" Then subds = tableProperty_FX("SubdatasheetName", topSource) LinkCF = klammeom(tableProperty_FX("LinkChildFields", topSource)) LinkMF = klammeom(tableProperty_FX("LinkMasterFields", topSource)) Else subds = QueryProperty_FX("SubdatasheetName", topSource) LinkCF = klammeom(QueryProperty_FX("LinkChildFields", topSource)) LinkMF = klammeom(QueryProperty_FX("LinkMasterFields", topSource)) End If
Function klammeom(strind As String) As String If InStr(strind, " ") Or InStr(strind, "-") Then strind = "[" & strind & "]" End If klammeom = strind End Function
Private Sub Kommandoknap4_Click() If cboT_V.Column(1) = "Table" Then DoCmd.OpenTable Me!cboT_V, , acReadOnly Else DoCmd.OpenQuery Me!cboT_V, , acReadOnly End If SendKeys "%IU" End Sub
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.