Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    mcktigger is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    19
    Hi

    Thanks for your help earlier in the week. All is working perfectly with creating new quotes.

    However now got an issue of how to handle the user going back and editing the records. I need to allow the user to edit prices on the form Frm68AQuotes which then propogates through to tblquotelines. Could your code be modified to an Update Query easily?

    Also need to handle if they go back and add another new product price. Currently your code would create new records causing duplicates. I tried amending it to

    If ctl.Tag = "ED" Then
    If ctl.Value > 0 Then
    if ctl.oldvalue = 0 then
    iProductID = DLookup("[ProductID]", "tblpricelist", "[FormName] = '" & ctl.name & "'")
    DoCmd.SetWarnings False
    DoCmd.RunSQL ("INSERT INTO tblQuoteLines (QuoteID, ProductID, SellPrice) VALUES (" & Me.QuoteId & "," & iProductID & "," & ctl.Value & ")")
    DoCmd.SetWarnings True


    End If
    End If
    End If
    Next

    But this is not doing anything - no error and no table update.

    Thanks again.

  2. #17
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    That would still create a record (might fail if it hits a key violation). To modify an existing record with SQL you'd run an update query, the basic syntax of which is:

    UPDATE TableName
    SET FieldName = 123
    WHERE FieldName = 123
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #18
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    This is a bit of a trickier situation. with each row that has a value in the first column you would have to check to see if there's an existing record, if there is, update it, if there isn't run the insert query.

    And as pbaldy said, you'd want to generate an UPDATE query for any item that has a value that is not currently in your database.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Creating multiple records from a single form
    By secretary in forum Forms
    Replies: 8
    Last Post: 07-18-2011, 04:03 PM
  2. Create Multiple Charts from Single Table
    By Catch Wrestler in forum Reports
    Replies: 0
    Last Post: 06-17-2010, 08:33 AM
  3. Create multiple records with 1 form?
    By bergjes in forum Forms
    Replies: 4
    Last Post: 04-14-2010, 06:16 AM
  4. Trying to create multiple records from a form
    By ed_hollywood in forum Forms
    Replies: 4
    Last Post: 04-02-2010, 10:57 PM
  5. Replies: 3
    Last Post: 06-01-2009, 01:41 PM

Tags for this Thread

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