Results 1 to 3 of 3
  1. #1
    kagoodwin13 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    181

    Update Master Table with Temporary Table

    I was given a project in which I must take a very inefficient method of gathering, organizing, and entering data, and make it work.

    That being said, here is what I am faced with:

    I have an Excel file that I must input into the master table. The Excel file, temporary table, and master table are all structured the same. The table is structured like this:
    PART_NUMBER OCT13 NOV13 DEC13
    1234567890 1000 1000 1000
    1234567891 2000 2000 2000
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0


    The Excel input form was designed to handle 100 part numbers, even if a particular input only required 1 or 2 part numbers. Therefore, there are a whole lot of zeros that must be stripped before I can work with it.

    The best process I can think of is:
    1. Make an input form with tblTEMP as the Recordset (Done)
    2. Create a button to execute TransferSpreadsheet into a temporary table (Done)
    3. Strip the records with "0" part number (DELETE * FROM tblTEMP WHERE PART_NUMBER = '0')
    4. Update the master table with results that are left


    So far I have this code, but I seem to be getting the syntax wrong:


    Code:
    UPDATE tblMASTER SET OCT13 = & Me.OCT13 &
    I am also needing to set up a For loop, something like:
    Code:
    For Each PART_NUMBER in tblTEMP, run the update query
    Thanks for any help you can provide! If you have any other ideas on how to input this data, please let me know.

  2. #2
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    If you've already created the temp table with the records in it, you shouldn't have to loop anything. If you just want to update the MASTER tabel with the values in the TEMP table, then use something like this -
    Code:
    strSQL = "UPDATE tblMASTER, tblTEMP " & _
             "SET tblMASTER.OCT13 = tblTEMP.OCT13 " & _
             "WHERE tblMASTER.PART_NUMBER = tblTEMP.PART_NUMBER;"
    docmd.runsql strSQL
    


    There's a little more code you should have around it - error trapping and so on, but that's the basics.

    Appending the temporary records into the master is just as easy.




  3. #3
    kagoodwin13 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    181
    Thanks, that worked!

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

Similar Threads

  1. Item Master List | Products Table
    By namu23 in forum Access
    Replies: 4
    Last Post: 10-02-2013, 10:33 PM
  2. Replies: 2
    Last Post: 03-13-2013, 06:30 AM
  3. Replies: 11
    Last Post: 04-04-2012, 05:48 PM
  4. Replies: 5
    Last Post: 03-23-2012, 11:40 AM
  5. Increment number from master table
    By leighturner in forum Queries
    Replies: 1
    Last Post: 12-08-2010, 08:19 AM

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