Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2010
    Posts
    5

    Form that creates records from a template

    I'm trying to create a "template" form where the user can duplicate a set of records but modify a certain number of fields. for example, PC1 exists in the database and has 35 parts related to it. the user wants to be able to create a new pc, PC2, with the same 35 parts. instead of inputting each part individually i want the user to be able to create PC2 based off of PC1 but renaming it PC2 and changing who the "record updater" is for that pc. the steps i got planned are:

    1. Duplicate and Append records to Temporary Table
    2. Update records in temporary table based on user input.


    3. Append results to main table
    4. Delete records in Temporary table.

    i have step one complete using an append query, but im stuck on the update query for step 2. the SQL im using for the update query is

    Code:
     
    UPDATE tblTemporary SET tblTemporary.AssemblyNumber = DLookUp("ID","tblTopAssembly","AssemblyNumber"=forms!frmUpdateTempTable!txtAssemblyNumber), tblTemporary.Updater = [Forms]![frmUpdateTempTable]![cboUpdater];
    theres a pop-up form "frmUpdateTempTable" where the user selects the updater for the new set of records (cboUpdater) and types in the assembly number (txtAssemblyNumber). The record on this form is supposed to be saved to the table "tblTopAssembly" first then the the value typed in txtAssemblyNumber is passed to the records in tblTemporary. the updater is passed correctly, but the Assembly number isnt. the value stored in the temporary table for assembly number is the AutoNumber ID that corresponds to the AssemblyNumber that the user typed in. Any suggestions on how to successfully pass this value to tblTemporary or notes on whats wrong with my SQL? thanks in advance

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Is the field Assembly Number a text datatype? If so, use apostrophe delimiters and think DLookup syntax needs concatenation:

    "AssemblyNumber='" & forms!frmUpdateTempTable!txtAssemblyNumber & "'"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Join Date
    Jun 2010
    Posts
    5
    No its not , the "AssemblyNumber" field in the table "tblTemporary" is a ID number that correlates to the text of the actual "Assembly Number" that the user types in. if what im saying makes sense...

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Then try what I suggested without the apostrophes but still concatenate.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Join Date
    Jun 2010
    Posts
    5
    can you clarify what im supposed to concatenate? the ampersands give me an error saying that there's an extra " ) " in the DLookup statement. however, that is needed to close out the dlookup

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    UPDATE tblTemporary SET tblTemporary.AssemblyNumber = DLookUp("ID","tblTopAssembly","AssemblyNumber=" & forms!frmUpdateTempTable!txtAssemblyNumber), tblTemporary.Updater = [Forms]![frmUpdateTempTable]![cboUpdater];
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Join Date
    Jun 2010
    Posts
    5
    I finally figured it out! It was a syntax error. I had to put a quotation around [forms]![frmUpdateTempTable]![txtAssemblyNumber] so that access recognizes the value as a text. The correct SQL code now is

    Code:
    UPDATE tblTemporary SET tblTemporary.AssemblyNumber = DLookUp("ID","tblTopAssembly","AssemblyNumber = " & '[forms]![frmUpdateTempTable]![txtAssemblyNumber]'), tblTemporary.Updater = [Forms]![frmUpdateTempTable]![cboUpdater];

    thanks for the help June7
    Last edited by techaddiction7; 07-20-2011 at 05:52 AM. Reason: PROBLEM SOLVED

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

Similar Threads

  1. Concat in SQL creates unwanted spaces
    By Deutz in forum Access
    Replies: 3
    Last Post: 12-07-2010, 11:43 PM
  2. Replies: 5
    Last Post: 10-28-2010, 09:48 PM
  3. subform creates duplicate record
    By jheintz57 in forum Forms
    Replies: 0
    Last Post: 03-29-2010, 11:50 AM
  4. Open form which creates new record
    By mjhopler in forum Forms
    Replies: 7
    Last Post: 02-09-2010, 01:37 PM
  5. Form that runs query and creates reports
    By Valeda in forum Forms
    Replies: 2
    Last Post: 05-04-2006, 07:01 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