July 3, 2008 at 12:53 am
Hey.
I havae a dbase in Access 2000 but now it's migrating to Sql server 2005.
I have changed and put almost everything to work except this one :
Option Compare Database
Option Explicit
'represents the tree view on the form
Private WithEvents tvw As MSComctlLib.TreeView
Private Sub cmdPrint_Click()
DoCmd.OpenReport "rapDokumentyZalaczone", acViewPreview
End Sub
Private Sub Form_Open(Cancel As Integer)
Set tvw = Me.ctrlTreeView.Object
End Sub
Private Sub Form_Current()
Dim IDUmowy As Integer
IDUmowy = podajIdUmowy
initTreeView IDUmowy
End Sub
Public Sub initTreeView(IDUmowy As Integer)
Dim sql As String
tvw.Nodes.Clear
'add a root node
tvw.Nodes.Add , , "xRoot", "Repozytorium dokumentów"
'create an SQL statement to drive the first level of node creation
'this is a recordset of reviewers, but rst fieldnames are changed
'to 'Key' and 'Text' so the node creation routine can be generic
'note that we prefix the key with an 'r' to distinguish it from case keys
sql = "SELECT * FROM kwKDKategorie;"
'call the create routine, passing in the sql as above, and the key of the parent node, in this case "Root"
CreateTree sql, "xRoot"
' Exit Sub
'initTreeView_err:
' Debug.Print "frmKDKatalogDokumentow; " & Err.Source & "; " & Err.Description
End Sub
Public Sub CreateTree(sql As String, parentKey As String)
Dim rst As ADODB.Recordset
Dim nd As MSComctlLib.Node
Dim strSQL As String
'open an r-set, whose definition is not know at run-time
'but it must have the two fields: Key, and Text
Set rst = CurrentProject.Connection.Execute(sql)
With rst
'traverse all its records
Do While Not .EOF
'adding a node for every one
Set nd = tvw.Nodes.Add(parentKey, tvwChild, !tKey, !tText)
'if this is a reviewer, then add cases
If Left(!tKey, 1) = "r" Then
'make sure reviewers are visible
nd.EnsureVisible
'now add any child nodes of the current reviewer by calling CreateTree with different parameters
'and in the WHERE clause, the prefixed character (r, in this case) is removed using Mid()
strSQL = "SELECT tKey, tText FROM kwKDListaDok WHERE KatalogID=" & Mid(!tKey, 2) & ";"
CreateTree strSQL, !tKey
End If
'move to the next record
.MoveNext
Loop 'while not .eof
.Close 'rst
End With
End Sub
Private Sub Polecenie9_Click()
Me.sfmGeneric.SourceObject = "pdfrmKDDokumentDodawanie"
End Sub
Private Sub tvw_NodeClick(ByVal Node As MSComctlLib.Node)
Select Case Left(Node.Key, 1)
Case "x"
'show blank subform
Me.sfmGeneric.LinkChildFields = ""
Me.sfmGeneric.SourceObject = "pdfrmKDKatalogDokumentow"
Case "r"
'show reviewer subform
Me.sfmGeneric.SourceObject = "pdfrmKDGRupaDokumentow"
Me.sfmGeneric.LinkChildFields = "KatalogID"
Case "c"
'show case subform
Me.sfmGeneric.SourceObject = "pdfrmKDDokument"
Me.sfmGeneric.LinkChildFields = "DokumentID"
End Select
Me.tbLink = Mid(Node.Key, 2)
Me.sfmGeneric.Form.Requery
End Sub
I mean it was working in access 2000 i have changed some lines to Ado and it's showing in sql 2005 but it not showing things as it should and as it was in access 2000 and mostly it crush application or show error in line:
Me.sfmGeneric.LinkChildFields = "KatalogID"
with error code 2101 and some unclear txt.
Could anyone help me with this one?
Very big thanks for any help
July 4, 2008 at 11:19 am
Extracted from your post
CreateTree sql, "xRoot"
Calls this subroutine
Public Sub CreateTree(sql As String, parentKey As String)
Dim rst As ADODB.Recordset
Dim nd As MSComctlLib.Node
Dim strSQL As String
'open an r-set, whose definition is not know at run-time
'but it must have the two fields: Key, and Text
Set rst = CurrentProject.Connection.Execute(sql)
Think you have miss copied your code to this post as I do not see where the original (passed in sql text) is modified to use the parentkey value.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply