Results 1 to 4 of 4
  1. #1
    Datech is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    40

    Macro or VBA to auto-magically create/copy a form?

    Short: Is it possible to have a macro or a VB script that creates a form based simply off of a record addition to a table?



    Long: It sounds drastic, and might not be the right way to approach this, but here's the context:

    We have "Owners" who report certain employees working on certain jobs. For input and verification purposes, we have a form that shows what employees/jobs combinations are under a certain Owner. All Owners are able to see (and edit, if necessary) any other Owner's form as well, so we don't need to worry about restrictions. I'll be using a switchboard form with a drop down list that shows all of these Owner forms (Daniel's Employees, Patrick's Employees, etc), with a button that takes them to that form so they can do their changes as needed. The Owners are specified in a table, and the one-to-many relationship is defined in the table that ties employees to projects.

    What I want to know is if I add an owner to the Owners table, is there a way to automatically copy the layout of another Owner form (Daniel's Employees) and change it so that the new Owner's name is populated in the appropriate places (like the form title) and the functionality (pulling up NewOwner's employees instead of Daniel's) is matched to the new owner as well?

    After typing all this it seems like the code for it would be a lot worse than just creating the individual forms myself. We won't have too many owners, but I guess I'm just asking in the spirit of automation. For those that know, a simple Yes or No will suffice. We'll work on the code later if it can be done. I'll be working on some of this tonight and tomorrow, so I should be able to provide a test DB if someone really wants it.

    I've been able to put my nose through a few relevant chapters of The Missing Manual, and thanks for everyone's patience so far with some of my questions . I'm still against the clock with not enough experience and not enough time to learn. Such is employment...

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Well, I won't say it can't be done, but it would be highly unusual. Why do you have different forms for each owner? You don't have separate tables, do you? Normally I'd expect to have one table with the owner's data, and filtering a single form to view the desired owner's data. There would likely be other tables for other things, but the point is you shouldn't have multiple tables for similar data.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Datech is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    40
    Quote Originally Posted by pbaldy View Post
    Well, I won't say it can't be done, but it would be highly unusual. Why do you have different forms for each owner? You don't have separate tables, do you? Normally I'd expect to have one table with the owner's data, and filtering a single form to view the desired owner's data. There would likely be other tables for other things, but the point is you shouldn't have multiple tables for similar data.
    I was reading Ch 14 on designing a navigation system, and thumbed back to Ch 13 about building advanced forms. I just need to read all the form chapters front to back before I go forward, probably. I don't think the automation would be worth it, even if the other stuff is the direction I want to head.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    You haven't said what your table structure is, but I would head for the chapter on normalization. Properly designed tables are the foundation an application is built on, and should be the first thing done.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 06-06-2011, 04:18 PM
  2. VBA to create Excel sheet and a copy as PDF
    By MichaelC in forum Programming
    Replies: 2
    Last Post: 05-04-2011, 02:32 PM
  3. Can't create a simple macro......
    By Sarge, USMC in forum Access
    Replies: 1
    Last Post: 01-05-2011, 11:48 AM
  4. Create Hash - Copy File to string
    By andrew_ww in forum Programming
    Replies: 0
    Last Post: 03-20-2010, 02:14 AM
  5. how to create a macro or code to...
    By Eaglezinha in forum Access
    Replies: 1
    Last Post: 10-20-2008, 04:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums