Arthur Fuller
artful at rogers.com
Mon Jan 23 20:54:37 CST 2006
Thank you to those who pointed you at my previous efforts to solve the treeview problem, but IMO that code is obsolete and there is a much slicker way to skin this particular cat. I have not yet written it up formally, but here is the skinny: Assuming that you have 3 tables or queries (GrandParent, Parent and Child), try this: 1. Set up the relationships as above, with Referential Integrity; 2. Create an AutoForm for each table (this to be replaced/enhanced when you're ready); do this inside out (i.e. start at Child then work your way out). 3. The Parent form should have an embedded subform which refers to the Child table itself. Switch this to refer to the form you created for the Child. 4. Do the same on the Grandparent level, switching its subform reference to the Parent form. 5. Change the default display of the Parent form to Databasheet. 6. Change the default display of the Grandparent form to Datasheet. 7. Run the Grandparent form. This should result in a treeview. Expanding its nodes should take you to each sublevel. Each level will appear in DataSheet format, which admittedly is a problem. To fix this: 1. Make each of these forms read-only. 2. Write code for each double-click event on each level that pops open a form in dialog mode. (i.e. suppose top level is Customers; create a form Customers_Edit_frm that opens an edit form using the selected CustomerID as its parameter, allowing no navigation; and so on, down the tree). You will end up with a much smarter treeview that you might have coded using the treeview object. Trust me. Been there, done it. It works a treat. You will end up with a very smart UI that knows which node you just selected and opens the corresponding form, pointed at the node you just selected, no matter how many levels deep you choose to go. With almost no code, it will work just as you dreamed it might. When I get around to it, I will write this up formally, but in the interim this ought to be enough to get you there. I have delivered this UI twice recently, to two different clients, and both were totally wowed. Why? Not because of my slick code, of which there is almost none, but because it works exactly like Windows Explorer, Outlook and a dozen other apps they like. I didn't invent this, I just emulated it. HTH, Arthur -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Boyd, Mark Thomas (US - Philadelphia) Sent: January 23, 2006 5:25 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Tree View Control Thanks Stuart. I agree, I probably don't want to use the Tree View control. I'm using linked forms, but I'd like for the child data to display directly underneath the parent record on the continuous form. Placing the child data in the form footer is a nice concept, but displays too far down on the form. Again, what I hope to do is make the data display a certain way. If there isn't a clean way of doing it, I have no problem using one of your suggestions. Thanks again. Mark Boyd Senior Consultant Enterprise Risk Services Deloitte & Touche LLP Tel: +1 215 405 5576 mboyd at deloitte.com www.deloitte.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan Sent: Monday, January 23, 2006 5:04 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Tree View Control On 23 Jan 2006 at 13:59, Boyd, Mark Thomas (US - Phila wrote: > I have the need to use a Tree View control on a form. > Basically, I have a continuous form, with a number of records containing > Account #'s. I want the user to be able to click a tree node "+" button, > and have detail records for this Account # displayed below. Within this > detail data, the user will need to update specific fields (combo boxes and > checkboxes). > > Is the Microsoft Tree View control capable of this? If not, are there > other controls that have this capability? > Any sample code would be greatly appreciated. > If you need to update child records, I would not try to use a treeview, I would use linked forms Depending on the visual requirements you can do either of the following: 1. A continuous form (frmsubDetails) in the form_footer of your Accounts form with its parent set to the key field in the main form. 2. An unbound main form with two sub forms side by side. A continous subform (frmsubAccounts) on the left which lists all of the accounts. A hidden text box (txtAccountLink) with a control source of "=frmSubAccounts.Key" A continuous subform (frmsubDetails) on the right containing the detail records. Set the Parent Field of frmsubDetails to "txtAccountLink" In either case, when you click on an Account record, the appropriate records will be displayed in frmsubDetails and can be edited. -- Stuart -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message. Any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. [v.E.1] -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com