Can I have one form save information to 2 tables?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • slenish
    Contributor
    • Feb 2010
    • 283

    Can I have one form save information to 2 tables?

    Hello everyone that is reading this,

    What I want to do is have my form be able to save the information you type in to 2 seperate tables. I have one table we can call the MasterTable that will save everything that is typed in. The second Table we can call (SubTable) I only want to save parts of the information. Not everything like the MasterTable. I tried to set up a relationship linking parts of the two tables together but that does not seem to work. I know that it can be done just wondering how?

    Thanks in advance
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #2
    This is sort of possible, speaking generally, but I suspect that you would like the same data store to more than one field. IE. One in one table, and another in the other one. Let's talk some fundamentals for a second.
    1. If the RecordSource for a form is a query, and that query is formed of multiple tables linked together AND is updatable (See Reasons for a Query to be Non-Updatable), then that form can write to multiple tables concurrently.
    2. Each control on the form can be bound to only one field from your RecordSource. If you had a control [First Name] for instance, and this was required in both of your tables, it could not be bound to both.
    3. With a little VBA work and some imagination, you could create a bunch of other controls on your form, which may be invisible, and these could be made duplicates of the ones you can see. These could then be bound to your alternative table fields. I suggest the code could go in your control AfterUpdate event procedures, but I would consider using the form's BeforeUpdate procedure instead. That way all code need only be processed once, when you're sure it's required.

    Comment

    Working...