Results 1 to 13 of 13
  1. #1
    Join Date
    Oct 2005
    Posts
    87

    Unanswered: Autofill table with records

    I was wondering if it is possible to do some kind of automatic record fill in one table, while you fill in manually records in another.

    E.g. there is table1 that has field1 field2 field3, and table2 that has field1 field2 field3.

    You manualy fill fields in table1 (through form), and then you press a button, and all three fields in table2 fill up themselves with the same records from table1.

  2. #2
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    You don't need the two tables with the same data,
    (only foreign key).

  3. #3
    Join Date
    Oct 2005
    Posts
    87
    Quote Originally Posted by MStef-ZG
    You don't need the two tables with the same data,
    (only foreign key).

    Any example of VBA (SQL) code?

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    What I think Mstef-ZG is gettign at is why duplicate the data in a second column within the same database. with proper design, unless you have soem really wacky requirement there is no need to dplicate the information.

    Often this sort of issue is triggered by an audit trail requirement (ie what was the original record).

    If you are erally certain that you have a good / valid requirement you could popluate the other table using the forms 'afterupdate' and post the values to the other table. its not a good solutiuon but it would work. you wil need to open the 'other table' on opening the form, and close it on the forms close. You wil need to consider how you will handle duplicates (ie changes tot he data) and deletions

    perhaps you could provide some more information on what you are trying to achieve

  5. #5
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    If you want to use this three fields as foreign key,
    make a MAIN FORM on tbale1, and a SUBFORM on table2.
    Relationships 1 to many.

  6. #6
    Join Date
    Oct 2005
    Posts
    87
    Quote Originally Posted by healdem
    What I think Mstef-ZG is gettign at is why duplicate the data in a second column within the same database. with proper design, unless you have soem really wacky requirement there is no need to dplicate the information.

    Often this sort of issue is triggered by an audit trail requirement (ie what was the original record).

    If you are erally certain that you have a good / valid requirement you could popluate the other table using the forms 'afterupdate' and post the values to the other table. its not a good solutiuon but it would work. you wil need to open the 'other table' on opening the form, and close it on the forms close. You wil need to consider how you will handle duplicates (ie changes tot he data) and deletions

    perhaps you could provide some more information on what you are trying to achieve

    There is a Form, where user fills all fields with different values e.g. product names, prices,date and so on. If he press one button, the names of these products "goes" to another table, in other words copy of certain fields (values) is made.
    But not all products and not all fields should be copied, there are some conditions.

  7. #7
    Join Date
    Oct 2005
    Posts
    87
    Quote Originally Posted by MStef-ZG
    If you want to use this three fields as foreign key,
    make a MAIN FORM on tbale1, and a SUBFORM on table2.
    Relationships 1 to many.

    But this way , both tables must have the same number of fields...and in my case it isn't.

    And i think this way i can't create conditions...

  8. #8
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372

    Hello YZF!

    Here it is.
    Look at "DemoAutomaticFillA2000.mdb".
    Enter new record, and look in the tables.
    Attached Files Attached Files

  9. #9
    Join Date
    Oct 2005
    Posts
    87
    Quote Originally Posted by MStef-ZG
    Here it is.
    Look at "DemoAutomaticFillA2000.mdb".
    Enter new record, and look in the tables.

    Yes, it can work using "append query".

    But if number of fields differ, will it work? how?

  10. #10
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    I don't know what do you exactly want.
    If the number of fields differ, it will not work.
    You have to write this data via another form.

  11. #11
    Join Date
    Oct 2005
    Posts
    87
    Quote Originally Posted by MStef-ZG
    I don't know what do you exactly want.
    If the number of fields differ, it will not work.
    You have to write this data via another form.
    I have a form of 50 fields.Each field has product name.All products belong to one category, but there are some of them that belong to "extra" category.

    On certain condition (e.g. button press), i want to copy 20 "extra-products" (20 fields) from this form to another table.These 20 extra-products are entered into 20 random fields in this form. I don't need to copy all 50 fields only selected 20.

    With append query it won't work, is there any other way to make it work?

  12. #12
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    come again, you have a row with 50 fields, each of which is a different product?


    - sounds like your physical (table) design is suspect, or at least needs revisiting.

  13. #13
    Join Date
    Oct 2005
    Posts
    87
    Quote Originally Posted by healdem
    come again, you have a row with 50 fields, each of which is a different product?


    - sounds like your physical (table) design is suspect, or at least needs revisiting.

    Well it was more of an example, but the main idea is that i don't need to copy all fields, only selected ones.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •