Results 1 to 3 of 3
  1. #1
    mukky is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2010
    Posts
    1

    paste values from one table to another table in form

    Hello,



    please can you help me ?

    i need insert values from table tbl_parts (column 1,2,3...) to tbl_materials - in tbl_materials is primary key. the values will be inserted if form is on load

    1 Table tbl_materials
    columns
    MainID, MatID, PN, Desc, Suplier, quantity

    2 Table tbl_parts(lines are filled)
    MatID, PN, Desc, Suplier, quantity

    i have this code, but i dont know define primary key, and access say error Run-time 3075

    DoCmd.RunSQL "INSERT INTO tbl_materials (MatID, PN) SELECT (MatID, PN) FROM tbl_parts"

    i need insert to field "quantity" for each record another values

    thank you for help

    if you understand something to write
    sorry for my English

  2. #2
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    I'm more of an ADO versus DAO coder (and like to work with queries in design view) but what I might do is design the update query itself and save it (ie. qryUpdateMyRecs) making sure it updates the appropriate recs with the criteria I wanted.

    and then in code you could just run the query...

    docmd.openquery "qryUpdateMyRecs"

    or once you design the query in the designer, change it to SQL view and then copy/paste the syntax in your code (you may have to remove a couple of ")

  3. #3
    KathyL is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    94
    From your post, we can’t tell some things. When you are trying to update/or/insert data into your 2nd table, we can’t know if the record already exists in your 2nd table. You might want to take that into consideration. My approach, would be to consider a regular access query which could be executed, which would do the update of table 2.

    The other thing is, if you are designing a relational database, why are you replicating the same information by MatID into a 2nd table? It seems like you would just want to access the original information in table 1 and not replicate data.

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

Similar Threads

  1. Replies: 8
    Last Post: 02-19-2012, 03:48 PM
  2. Replies: 2
    Last Post: 06-06-2011, 04:18 PM
  3. Display values in a FORM from table.
    By excelkeechak in forum Forms
    Replies: 3
    Last Post: 05-04-2010, 10:17 AM
  4. Replies: 3
    Last Post: 04-04-2010, 05:26 PM
  5. Replies: 0
    Last Post: 10-15-2009, 02:08 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