p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access (http://p2p.wrox.com/forumdisplay.php?f=18)
-   -   Create Dynamic Form; end-user adds/drops columns (http://p2p.wrox.com/showthread.php?t=28780)

pkaptein1 April 30th, 2005 08:36 PM

Create Dynamic Form; end-user adds/drops columns
 
In forms I've customized for clients in the past, I've always placed each static field label in the form's header with corresponding variable table data in the form's detail. A current client wants to be able to add and delete columns, at will from a form she uses, via a GUI interface provided by MS Access. Can someone advise on how to design a form to be dynamic such that the end-user may pull into the form only the columns they need, or add new columns to an existing form, or drop unnecessary columns with columns maintaining headers?[?]

If you have done this in the past, would you be willing to attach or email me a sample Access Database or sample code? I am experienced with MS Access but somewhat of a novice with modules/vba code but very willing to learn what is needed to solve this matter!

rjweers May 1st, 2005 01:18 PM

The simplest way to accomplish this is to display the form in DataSheet view. Then teach your users how to use Access functionality.

E.g. Right click on a column heading and select "Hide Columns" to hide the column.

E.g. Right click on the form's caption and select "Unhide Columns..." to see a list of available columns to unhide.

Of course they can drag columns to reorder them and use "Freeze Columns" to keep them visible during right horizontal scroll.

No coding necessary!

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org

pkaptein1 May 1st, 2005 03:03 PM

Randall, Thank you for this solution and at one point I had been thinking along those lines; however, this dynamic form will also have a subform in it which must be viewed in form view rather than datasheet view. From my understanding, there is no way to have the main form show in datasheet view and subform show in form view. Is that correct?

rjweers May 1st, 2005 09:27 PM

You are correct... HOWEVER...

You could create a Master form. Then put the DataSheet view form and the single record form as subforms on that master.

Assuming that you want the single record form to display data from the selected record in the DataSheet view form, the trick then is how to link the item selected in the DataSheet form with the data in the single record form.

Actually, that's quite easy. In the OnCurrent event of the datasheet view, post the ID of the current record to a hidden text form on the master form. E.g.

Me.Parent.Form.txtHiddenID = Me.IDField

Then you Link the single record subform with that text field. NOTE: You can't use the wizard to set the Master and Child Link fields. You can type them in yourself.

pkaptein1 May 3rd, 2005 11:56 AM

To rjweers aka Randall: After spending an entire weekend trying to find a solution to this problem, with very complex advice from many experienced programmers, I think you solved it for me :) with a simple, no-nonsense approach! I am so very grateful for the posts you provided that ultimately helped me to resolve this issue. Many thanks! :D You are awesome!!

rjweers May 6th, 2005 07:13 AM

Just call me "simple" :D

Happy to be of service.

Alicia February 15th, 2006 03:32 AM

Quote:

quote:Originally posted by rjweers
 You are correct... HOWEVER...

You could create a Master form. Then put the DataSheet view form and the single record form as subforms on that master.

Assuming that you want the single record form to display data from the selected record in the DataSheet view form, the trick then is how to link the item selected in the DataSheet form with the data in the single record form.

Actually, that's quite easy. In the OnCurrent event of the datasheet view, post the ID of the current record to a hidden text form on the master form. E.g.

Me.Parent.Form.txtHiddenID = Me.IDField

Then you Link the single record subform with that text field. NOTE: You can't use the wizard to set the Master and Child Link fields. You can type them in yourself.
Hi I am trying to create a form (tabular) and a subform (datasheet) that works in the reverse order, whereby upon choosing the Student Name, it will display the subjects taken by the students, the lecturer teaching the subject and the grades of the subjects in the subform. Upon selecting one of the subjects it will be able to display the corresponding information in the form's textboxes for editing. Is this feasible. Can anyone kindly please advise how I can link the subforms back to the form i.e. when I select one entry in the datasheet of the subform, it will be display in the form for editing purposes? Thanks alot.



All times are GMT -4. The time now is 11:21 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.