{"id":592,"date":"2010-08-26T13:20:19","date_gmt":"2010-08-26T12:20:19","guid":{"rendered":"http:\/\/www.venco.com.pl\/~cozy\/blog\/?p=592"},"modified":"2010-08-26T13:20:19","modified_gmt":"2010-08-26T12:20:19","slug":"treeview-w-ms-access","status":"publish","type":"post","link":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/2010\/08\/26\/treeview-w-ms-access\/","title":{"rendered":"TreeView w MS Access"},"content":{"rendered":"<p>Private Sub Form_Load()<br \/>\nFillStructureTree<br \/>\nEnd Sub<!--more--><\/p>\n<p>Sub FillStructureTree()<br \/>\nDim xTree As MSComctlLib.TreeView<br \/>\nDim sql As String<br \/>\nDim rsBoss As DAO.Recordset<br \/>\nDim rsBiuro As DAO.Recordset<br \/>\nDim rsTeam As DAO.Recordset<br \/>\nDim strSKU As String<br \/>\nDim strPartDescription As String<br \/>\nDim strPartNumber As Integer<br \/>\nDim strSKUkey As String<br \/>\nDim strPartKey As String<br \/>\nDim strSql As String<br \/>\nDim wydzialID As Integer<\/p>\n<p>Set xTree = Me.tvStructure.Object<\/p>\n<p>'wczytanie danych od dyrektorach<\/p>\n<p>sql = &#8222;SELECT Wydzia\u0142y.ID_Wydzia\u0142, [IMIE] &amp; &#8217; &#8217; &amp; [Nazwisko] AS boss &#8221; &amp; _<br \/>\n&#8222;FROM Wydzia\u0142y INNER JOIN Pracownicy ON Wydzia\u0142y.ID_Prac = Pracownicy.ID_Prac &#8221; &amp; _<br \/>\n&#8222;WHERE (((Wydzia\u0142y.poziom) = 0 Or (Wydzia\u0142y.poziom) = 1)) &#8221; &amp; _<br \/>\n&#8222;ORDER BY Wydzia\u0142y.poziom, Wydzia\u0142y.[Nazwa wydzia\u0142u];&#8221;<\/p>\n<p>Set rsBoss = CurrentDb.OpenRecordset(sql)<\/p>\n<p>Do While Not rsBoss.EOF<br \/>\nstrSKU = rsBoss.Fields(&#8222;boss&#8221;) 'pobranie informacji jak nazywa si\u0119 dyrektor<br \/>\nstrSKUkey = &#8222;SKU&#8221; &amp; rsBoss.Fields(&#8222;ID_Wydzia\u0142&#8221;) 'pobranie informacji o numerze identyfikacyjnym jednostki<br \/>\nwydzialID = rsBoss.Fields(&#8222;ID_Wydzia\u0142&#8221;)<br \/>\nxTree.Nodes.Add , , strSKUkey, strSKU 'utworzenie ga\u0142\u0119zi I-go poziomu<\/p>\n<p>'podbranie informacji o kom\u00f3rkach podleg\u0142ych poszczeg\u00f3lnym dyrektorom<\/p>\n<p>sql = &#8222;SELECT Wydzia\u0142y.ID_Wydzia\u0142, Wydzia\u0142y.[Nazwa wydzia\u0142u]&#8221; &amp; _<br \/>\n&#8222;FROM Wydzia\u0142y INNER JOIN Pracownicy ON Wydzia\u0142y.ID_Prac = Pracownicy.ID_Prac &#8221; &amp; _<br \/>\n&#8222;WHERE Wydzia\u0142y.poziom = 2 And Wydzia\u0142y.Jed_nad =&#8221; &amp; wydzialID &amp; _<br \/>\n&#8221; ORDER BY Wydzia\u0142y.[Nazwa wydzia\u0142u];&#8221;<\/p>\n<p>Set rsBiuro = CurrentDb.OpenRecordset(sql)<\/p>\n<p>Do While Not rsBiuro.EOF<br \/>\nstrPartKey = &#8222;Part&#8221; &amp; rsBiuro.Fields(&#8222;ID_Wydzia\u0142&#8221;)<br \/>\nstrPartDescription = rsBiuro.Fields(&#8222;Nazwa wydzia\u0142u&#8221;)<br \/>\nwydzialID = rsBiuro.Fields(&#8222;ID_Wydzia\u0142&#8221;)<\/p>\n<p>xTree.Nodes.Add strSKUkey, tvwChild, strPartKey, strPartDescription<\/p>\n<p>'pobranie informacji o kom\u00f3rkach w ramach danej kom\u00f3rki organziacyjnej<\/p>\n<p>sql = &#8222;SELECT Wydzia\u0142y.ID_Wydzia\u0142, Wydzia\u0142y.[Nazwa wydzia\u0142u] &#8221; &amp; _<br \/>\n&#8222;FROM Wydzia\u0142y INNER JOIN Pracownicy ON Wydzia\u0142y.ID_Prac = Pracownicy.ID_Prac &#8221; &amp; _<br \/>\n&#8222;WHERE Wydzia\u0142y.poziom = 3 And Wydzia\u0142y.Jed_nad = &#8221; &amp; wydzialID &amp; _<br \/>\n&#8221; ORDER BY Wydzia\u0142y.[Nazwa wydzia\u0142u];&#8221;<\/p>\n<p>Set rsTeam = CurrentDb.OpenRecordset(sql)<\/p>\n<p>Do While Not rsTeam.EOF<\/p>\n<p>strTeamKey = &#8222;Team&#8221; &amp; rsTeam.Fields(&#8222;ID_Wydzia\u0142&#8221;)<br \/>\nstrPartDescription = rsTeam.Fields(&#8222;Nazwa wydzia\u0142u&#8221;)<\/p>\n<p>xTree.Nodes.Add strPartKey, tvwChild, strTeamKey, strPartDescription<\/p>\n<p>rsTeam.MoveNext<\/p>\n<p>Loop<\/p>\n<p>rsBiuro.MoveNext<\/p>\n<p>Loop<\/p>\n<p>rsBoss.MoveNext<\/p>\n<p>Loop<\/p>\n<p>End Sub<\/p>\n<p>'obs\u0142uga klikni\u0119cia na dowolnym w\u0119\u017ale. Wystarczy utworzy\u0107 procedur\u0119 bez \u017cadngo 'wi\u0105zania z obiektem. Wa\u017cne aby\u00a0 w nazwie procedury by\u0142a nazwa obiektu, kt\u00f3rego ona 'dotyczy &#8211; w tym wypadku tvStructure<\/p>\n<p>Private Sub tvStructure_NodeClick(ByVal selectedNode As Object)<\/p>\n<p>Debug.Print Val(selectedNode.Key) &amp; &#8221; &#8221; &amp; selectedNode.Text<\/p>\n<p>End Sub<\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">Private Sub Form_Load() FillStructureTree End Sub<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/2010\/08\/26\/treeview-w-ms-access\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[44,37,17,18],"class_list":["post-592","post","type-post","status-publish","format-standard","hentry","category-bez-kategorii","tag-access","tag-bazy-danych","tag-programowanie","tag-visal-basic"],"_links":{"self":[{"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/posts\/592","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/comments?post=592"}],"version-history":[{"count":0,"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/posts\/592\/revisions"}],"wp:attachment":[{"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/media?parent=592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/categories?post=592"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/tags?post=592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}