Link to home
Create AccountLog in
Microsoft Access

Microsoft Access

--

Questions

--

Followers

Top Experts

Avatar of Jeremy Campbell
Jeremy Campbell๐Ÿ‡บ๐Ÿ‡ธ

Need help getting a tree view (activex control) started in an access form.
I have seen some examples in the previous question I posted. I am just trying to get this started and I can't get the the structure (or anything really) to show up in my active x control.

I want to start this from scratch as it will help me understand it better rather than importing a template from an example..

To start though, for the sake of this question. Just need some help getting the Tree Activex view working by itself.

Here's what I have;

Created a new form, set my Record source to my query, qryJobTracker.

Here is the syntax for the query in case it affects this;
SELECT dbo_View_JobProd.jpJobNum, 
dbo_View_JobProd.jpTargetJobNum, 
dbo_View_JobAsmbl.jaAssemblySeq, 
dbo_View_JobAsmbl.jaPartNum, 
dbo_View_JobAsmbl.jaDescription, 
dbo_View_JobOper.joOprSeq, 
9999 AS jmMtlSeq,
dbo_View_JobOper.joOpDesc, 
dbo_View_JobOper.joCommentText
FROM (dbo_View_JobProd LEFT JOIN dbo_View_JobAsmbl ON dbo_View_JobProd.jpJobNum = dbo_View_JobAsmbl.jaJobNum) LEFT JOIN dbo_View_JobOper ON (dbo_View_JobAsmbl.jaAssemblySeq = dbo_View_JobOper.joAssemblySeq) AND (dbo_View_JobAsmbl.jaJobNum = dbo_View_JobOper.joJobNum)
WHERE (((dbo_View_JobProd.jpJobNum)=[Forms]![frmFAI]![cboJobNum])) OR (((dbo_View_JobProd.jpTargetJobNum)=[Forms]![frmFAI]![cboJobNum]))

UNION SELECT dbo_View_JobProd.jpJobNum, 
dbo_View_JobProd.jpTargetJobNum, 
dbo_View_JobAsmbl.jaAssemblySeq, 
dbo_View_JobAsmbl.jaPartNum, 
dbo_View_JobAsmbl.jaDescription,
9999, 
dbo_View_JobMtl.jmMtlSeq, 
dbo_View_JobMtl.jmPartNum, 
dbo_View_JobMtl.jmDescription
FROM (dbo_View_JobProd LEFT JOIN dbo_View_JobAsmbl ON dbo_View_JobProd.jpJobNum = dbo_View_JobAsmbl.jaJobNum) LEFT JOIN dbo_View_JobMtl ON (dbo_View_JobAsmbl.jaAssemblySeq = dbo_View_JobMtl.jmAssemblySeq) AND (dbo_View_JobAsmbl.jaJobNum = dbo_View_JobMtl.jmJobNum)
WHERE (((dbo_View_JobProd.jpJobNum)=[Forms]![frmFAI]![cboJobNum])) OR (((dbo_View_JobProd.jpTargetJobNum)=[Forms]![frmFAI]![cboJobNum]));

Open in new window


I added an ActiveX control CTreeView Control into my blank form. In design view nothing appears in the ActiveX control where as in the examples It shows some example tree.

Here is how my form looks;
User generated image
Here is how the example forms look;
User generated image
Thanks in advance for the assistance!

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


ASKER CERTIFIED SOLUTION
Avatar of Dale FyeDale Fye๐Ÿ‡บ๐Ÿ‡ธ

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

SOLUTION
Avatar of jcrozier21jcrozier21๐Ÿ‡ฆ๐Ÿ‡บ

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.

SOLUTION
Avatar of Helen FeddemaHelen Feddema๐Ÿ‡บ๐Ÿ‡ธ

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.

Avatar of Helen FeddemaHelen Feddema๐Ÿ‡บ๐Ÿ‡ธ

You need a data source for each level (typically a query), and you have to decide which fields to use for linking, and which for the visible text.

Avatar of Jeremy CampbellJeremy Campbell๐Ÿ‡บ๐Ÿ‡ธ

ASKER

Sorry I'm just getting back to you guys on this one.. I'm going to dig into this now and I'll get back as soon as I get hung up.

Thanks

Avatar of Jeremy CampbellJeremy Campbell๐Ÿ‡บ๐Ÿ‡ธ

ASKER

Thanks all for yout input.. I'm still struggling with this however.. ย 

fyed; I went through the episodes.. I focused on the actually structure of creating the tree. I managed to get two tiers setup.. The first is my Job Number which comes from a query, qryJobNums where I have the criteria set to Eval("[Forms]![frmFAI]![cboJobNum]"). (I only want one Job listed in the top tier of the tree.)

Then I added a second node under Job which I can get working if I specify the connection to Eval("[Forms]![frmFAI]![cboJobNum]") in the query qryJobAssemblies. If I remove the criteria from the query then I get a "Run-Time error '35601': Element not found"

Here is my code as of right now, when I'm getting the Element not found error. It highlights the part in bold;


Private Sub CreateJobNodes()
ย  Dim rst As DAO.Recordset ' recordset for category data

ย  ' open the recordset for categories
ย  Set rst = CurrentDb.QueryDefs!qryJobNums.OpenRecordset

ย  ' loop through the rows in the recordset
ย  rst.MoveFirst
ย  Do Until rst.EOF
ย  ย  Me.TreeJobTracker.Nodes.Add Text:=rst!jpJobNum, _
ย  ย  ย  Key:=CStr(rst!jpJobNum)
ย  ย  rst.MoveNext
ย  Loop
ย  rst.Close
ย  Set rst = Nothing
End Sub

Private Sub CreateAssemblyNodes()
ย  Dim rst As DAO.Recordset ' recordset for product data

ย  ' open the recordset for products
ย  Set rst = CurrentDb.QueryDefs!qryJobAssemblies.OpenRecordset

ย  ' loop through the rows in the recordset
ย  rst.MoveFirst
ย  Do Until rst.EOF
ย  ย Me.TreeJobTracker.Nodes.Add Relationship:=tvwChild, _
ย  ย  ย  ย  Relative:=CStr(rst!jpJobNum), _
ย  ย  ย  ย  Text:="ASM: "ย & rst!jaAssemblySeq &ย " "ย & rst!ParentPartNum ', _
ย  ย  ย  ย  'Key:="ASM=" &ย "Cstr(rst!jaAssemblySeq)"

ย  ย  ย  ย 
ย  ย  rst.MoveNext
ย  Loop
ย  rst.Close
ย  Set rst = Nothing
End Sub


Private Sub Form_Open(Cancel As Integer)
ย  CreateJobNodes
ย  CreateAssemblyNodes

End Sub


Right now the Key for my second Assembly node is commented out because I was getting an error on that as well. First if we can eliminate this element error though that would be good...

Thanks

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of Jeremy CampbellJeremy Campbell๐Ÿ‡บ๐Ÿ‡ธ

ASKER

Just figured out it was trying to find the next job number in the list which was not there because I filtered it out at my qryJobNums.. Now when I run it I'm getting a complete list of Jobs and then I can expand them to get to the assemblies within the jobs.

So I guess my question is, How can i filter the tree to only show me one job?

Avatar of Dale FyeDale Fye๐Ÿ‡บ๐Ÿ‡ธ

You cannot filter a tree.

The only thing I could think of would be hiding a node (which I have never attempted).

Or you set up the first part of the process (CreateJobNodes) so that it only builds the Job node for the job you are interested in.

Avatar of Jeremy CampbellJeremy Campbell๐Ÿ‡บ๐Ÿ‡ธ

ASKER

fyed.. I think I just made some headway with filtering.. I just need to filter the JobNum at every query for each node. That way only information pertaining to that specific job appears at any given query/node when the tree cycles through the data.

Now I'm trying to add a split in my tree though.. I'm thinking this might be simple and I just can't figure it out but I could be wrong:)

Basically I want to add different information under my assemblies; e.g.;

JobNum
ย  ย  ย  Assembly1
ย  ย  ย  ย  ย  ย  ย  ย Operations
ย  ย  ย  ย  ย  ย  ย  ย Materials
ย  ย  ย  Assembly2
ย  ย  ย  ย  ย  ย  ย  ย Operations
ย  ย  ย  ย  ย  ย  ย  ย Materials

I managed to add Operations in by itself no problem.. but I guess I need to add a node in between Assemblies and Operation that will create a split where I can add my operations under a node called operations and add materials under a node called materials..

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of Dale FyeDale Fye๐Ÿ‡บ๐Ÿ‡ธ

It can get very confusing as you go down. ย Another way to handle the differences between operations and materials, as items under each assembly would be to give them images that identify them as such. ย There is an example of that in episode #6 on the treeview blog.

Avatar of Jeremy CampbellJeremy Campbell๐Ÿ‡บ๐Ÿ‡ธ

ASKER

.. Hmm.. For some reason I thought it stopped at Episode 5 :) ย Sweet. Let me thumb through that and I'll get right back

Avatar of Dale FyeDale Fye๐Ÿ‡บ๐Ÿ‡ธ

What I usually do is build each node and its subnodes sequentially, sort of like:

set RsOuter = currentdb.openrecordset(strRootNodes, , dbfailonerror
while not rsOuter.Eof

ย  ย  Me.myTree.Nodes.Add ....

ย  ย  Call FirstLevel(rsOuter.SomeValue)

ย  ย  rsOuter.movenext
Wend
rsOuter.Close

Then, in FirstLevel, I use the value that was passed to create another recordset based upon that value, and loop through all of the records in that recordset. ย And if I have another level, I call that from inside subroutine FirstLevel, and pass it whatever parameter I need to.

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of Jeremy CampbellJeremy Campbell๐Ÿ‡บ๐Ÿ‡ธ

ASKER

I'm having trouble following your last post.. Probably because I'm still not fully onboard with how this is working:)

I can tell you what I have so far, the CreateCategoryNodes was my attempt at creating the operation subcategory.. Didn't work though.. Although I did get it to show up at the bottom of my tree as another primary tier..?

Option Compare Database

Open in new window


Private Sub CreateJobNodes()
  Dim rst As DAO.Recordset ' recordset for category data

  ' open the recordset for categories
  Set rst = CurrentDb.QueryDefs!qryJobNums.OpenRecordset

  ' loop through the rows in the recordset
  rst.MoveFirst
  Do Until rst.EOF
    Me.TreeJobTracker.Nodes.Add Text:=rst!jpJobNum, _
      Key:=CStr(rst!jpJobNum)
    rst.MoveNext
  Loop
  rst.Close
  Set rst = Nothing
End Sub

Open in new window


Private Sub CreateAssemblyNodes()
  Dim rst As DAO.Recordset ' recordset for product data

  ' open the recordset for products
  Set rst = CurrentDb.QueryDefs!qryJobAssemblies.OpenRecordset

  ' loop through the rows in the recordset
  rst.MoveFirst
  Do Until rst.EOF
    Me.TreeJobTracker.Nodes.Add Relationship:=tvwChild, _
        Relative:=CStr(rst!jpJobNum), _
        Text:="ASM: " & rst!jaAssemblySeq & " " & rst!ParentPartNum, _
        Key:=CStr(rst!jpJobNum) & CStr(rst!jaAssemblySeq)
        
    rst.MoveNext
  Loop
  rst.Close
  Set rst = Nothing
End Sub

Open in new window

Private Sub CreateOperationNodes()
  Dim rst As DAO.Recordset ' recordset for product data

  ' open the recordset for products
  Set rst = CurrentDb.QueryDefs!qryJobOperations.OpenRecordset

  ' loop through the rows in the recordset
  rst.MoveFirst
  Do Until rst.EOF
    Me.TreeJobTracker.Nodes.Add Relationship:=tvwChild, _
        Relative:=CStr(rst!jpJobNum) & CStr(rst!jaAssemblySeq), _
        Text:="Opr: " & rst!joOprSeq & " " & rst!jmDescription ', _
        Key:=CStr(rst!jpJobNum) & CStr(rst!jaAssemblySeq)
        
    rst.MoveNext
  Loop
  rst.Close
  Set rst = Nothing
End Sub

Open in new window

Private Sub CreateCategoryNodes()

Me.TreeJobTracker.Nodes.Add _
        Relationship:=tvwChild, _
        Relative:=CStr(rst!jpJobNum) & CStr(rst!jaAssemblySeq), _
        Text:="Operations", _
        Key:="Operations"

End Sub

Open in new window

Private Sub Form_Open(Cancel As Integer)
  CreateJobNodes
  CreateAssemblyNodes
  CreateOperationNodes
  CreateCategoryNodes
  
End Sub

Open in new window


SOLUTION
Avatar of Jeremy CampbellJeremy Campbell๐Ÿ‡บ๐Ÿ‡ธ

ASKER

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.

Avatar of Dale FyeDale Fye๐Ÿ‡บ๐Ÿ‡ธ

glad we could help.

Personally, I like the tree-view, but it can be annoying and time consuming to build, and they tend to take up a lot of screen realestate. Thank God for tabs.

Avatar of Jeremy CampbellJeremy Campbell๐Ÿ‡บ๐Ÿ‡ธ

ASKER

Between the different answers on here I was able to piece this together very well! The episodes you provided fyed helped me better understand how the thing was working.

Thank you all for your help!

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.

Microsoft Access

Microsoft Access

--

Questions

--

Followers

Top Experts

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.