473,385 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Idea for a fake treeview

I've a requirement for a treeview control to display a master-detail view.
So instead of the old the old 'ActiveX + 1,000 lines of code' method
that I've used in the past. I decided to try a different approach.

This is a very simple idea so I'd be surprised if it hasn't been done
before - but I couldn't find anything in google, so here it is if anyone is
interested.

The idea is to use a union query, where the first part of the union returns
the master records and the second part returns the selected detail. For
example, in the Northwind database, to show all orders with the expanded
details for a single selected order, you would conceptually do:

<select orders>
union
<select order detail for a single selected order>

A little formatting, and get your sorting right and you're in business. The
actual sql looks like this:

----------------------------------------------------------------------------------------------
select IIf(o.orderID=Forms![frmOrders].[txtOrderID],'-','+') AS rowID,
o.OrderID & ': ' & c.CompanyName as company,
format$(o.OrderDate, "medium date") as orderDate, 1 as detailLevel,
o.OrderID as sortOrder
from Orders as o inner join Customers as c on o.CustomerID=c.CustomerID

union all

select '', ' - ' & p.productName, null, 2, d.OrderID
from orderDetails as d
inner join products as p on d.ProductID = p.productID
where d.OrderID = Forms![frmOrders].[txtOrderID]

order by sortOrder, detailLevel;
----------------------------------------------------------------------------------------------
There's a trick to getting the '+' and '-' indicators and it's in the first
line of the query.

Place an invisible text box and a visible list box on your form. Set the
list's rowsource to the query above. Use code in
the lists OnDoubleClick event to place the selected OrderID in the text box,
(expand the detail), or replace it with zero if the orderID's match,
(close the detail).

Here's a screen shot:

http://www.assaynet.com/downloads/access/treeview.jpg

Anyway, this is a very simple example. There's a sample database at
http://www.assaynet.com/downloads/access/treeview.mdb if anyone is
interested, (Access 2002 format).

Of course there are lots of limitations. No images for one thing. No
multi-select. You can't expand more than one order, (that one should be easy
to solve though). Anyway, I'd like to know if anyone else has other ideas or
comments on duplicating treeview controls in Access. Or if anyone is
interested and wants to see some features let me know and I'll see if I
can get them put in.


Nov 13 '05 #1
4 2216
John,

What do the plus and minuses do?

Thanks,

Steve
"John Winterbottom" <as******@hotmail.com> wrote in message
news:38*************@individual.net...
I've a requirement for a treeview control to display a master-detail view.
So instead of the old the old 'ActiveX + 1,000 lines of code' method
that I've used in the past. I decided to try a different approach.

This is a very simple idea so I'd be surprised if it hasn't been done
before - but I couldn't find anything in google, so here it is if anyone is interested.

The idea is to use a union query, where the first part of the union returns the master records and the second part returns the selected detail. For
example, in the Northwind database, to show all orders with the expanded
details for a single selected order, you would conceptually do:

<select orders>
union
<select order detail for a single selected order>

A little formatting, and get your sorting right and you're in business. The actual sql looks like this:

-------------------------------------------------------------------------- -------------------- select IIf(o.orderID=Forms![frmOrders].[txtOrderID],'-','+') AS rowID,
o.OrderID & ': ' & c.CompanyName as company,
format$(o.OrderDate, "medium date") as orderDate, 1 as detailLevel,
o.OrderID as sortOrder
from Orders as o inner join Customers as c on o.CustomerID=c.CustomerID

union all

select '', ' - ' & p.productName, null, 2, d.OrderID
from orderDetails as d
inner join products as p on d.ProductID = p.productID
where d.OrderID = Forms![frmOrders].[txtOrderID]

order by sortOrder, detailLevel;
-------------------------------------------------------------------------- -------------------- There's a trick to getting the '+' and '-' indicators and it's in the first line of the query.

Place an invisible text box and a visible list box on your form. Set the
list's rowsource to the query above. Use code in
the lists OnDoubleClick event to place the selected OrderID in the text box, (expand the detail), or replace it with zero if the orderID's match,
(close the detail).

Here's a screen shot:

http://www.assaynet.com/downloads/access/treeview.jpg

Anyway, this is a very simple example. There's a sample database at
http://www.assaynet.com/downloads/access/treeview.mdb if anyone is
interested, (Access 2002 format).

Of course there are lots of limitations. No images for one thing. No
multi-select. You can't expand more than one order, (that one should be easy to solve though). Anyway, I'd like to know if anyone else has other ideas or comments on duplicating treeview controls in Access. Or if anyone is
interested and wants to see some features let me know and I'll see if I
can get them put in.


Nov 13 '05 #2

"Steve" <no****@nospam.spam> wrote in message
news:kV******************@newsread3.news.atl.earth link.net...
John,

What do the plus and minuses do?

Thanks,

Steve


They show you whether the order is expanded, (to show the order detail), or
not.
Nov 13 '05 #3
John,

Interesting idea. I tried something similar using subdatasheets, which
are basically nested subforms in datasheet view. You automatically get
your + and - boxes, and you can do multiple expansions.

It worked fine, except for one drawback: you couldn't get the
Form_Current event to fire reliably on a subdatasheet form (at least in
A2000). It simply wouldn't fire if there was just one record in the
child.

So, I went back to the ActiveX TreeView control. Its good to know that
there are simple, no-code solutions for situations where you don't need
the full capabilities of TreeView.

-Ken

Nov 13 '05 #4
John Winterbottom wrote:
to solve though). Anyway, I'd like to know if anyone else has other ideas or comments on duplicating treeview controls in Access. Or if anyone is


I like it. I did a treeview using VB6 with Access as the backend a few
years ago for a company that does corporate events that allowed them to
pick which event to edit or view. They would have been just as happy
with your idea.

James A. Fortune

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Fakhar | last post by:
Hi All, How can I check fake requests on my webpage. I am asking for email address as input and I wounder if anyone write a program to send fake requests and my system will be busy to respond...
42
by: lauren quantrell | last post by:
So many postings on not to use the treeview control, but nothing recently. Is it safe to swim there yet with Access 2000-Access 2003?
6
by: L.M | last post by:
Hello, I knew how to use the treeview under VB6. After migrating to .NET, well, I'm lost. I try to add a new node, either to the same level or as a child to a selected node in the treeview....
14
by: Mr.D | last post by:
How do I save/load the contents of a Treeview to a file? I have found several good examples written i VB6, but not a single one for VB.NET. Please help. ---- Tim
1
by: Alex D. | last post by:
hey guys I found what is causing the problems with my treeview in Firefox...the answer is: treeview+dropdwonlist in the same page dont work! try this simple code and see for yourselves. you can do...
1
by: kvicky | last post by:
I am trying to load child nodes to a TreeNode in a TreeView in a ASP.net web application. The Treeview with parent nodes are loaded on a Page_load while doing if( ! ISPostback ) and then in the...
2
by: pigeonrandle | last post by:
Hi, My application creates a project that is structured like a tree, so i want to use a treeview to display it to the user. Would it be a good idea to create the various parts of project as...
0
by: Falcula | last post by:
Hello, I have a treeview that i fill from a database, when i update nodename in database the treeview dont update. Its works when iam not useing enableviewstate="true" but then i loosing the...
0
by: Zuhaib Hyder | last post by:
TreeView node selection not working with PopulateOnDemand, any idea?? i want to select each node on click... even when any file opens in right frame in response of click on Treeview node on left...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.