Results 1 to 4 of 4
  1. #1
    Eason67 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2015
    Posts
    8

    Copying he value in a form to tale

    Having calculated a value on a form, I want to transfer this value to a table.




    I have some code but not sure its correct. I entered this into the after update section of the box with the calculated field in it.
    CurrentDb.Execute "INSERT INTO [tblBookings] (Total price) VALUES (" _
    & Me!Total price & ")", dbFailOnError

    ????

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    1. To prevent, dont put spaces in field names/text boxes, Use mixed case: TotalPrice

    2. use brackets, not parenthesis: [Total price] VALUES (" & Me![Total price] & ")", dbFailOnError

    3. you dont need ANY code, connect the form to the table, then just type in the TotalPrice box. The data goes in without any code.

  3. #3
    Eason67 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2015
    Posts
    8
    OK so I've tried this and it doesn't seem to work.

    The calculated value works. It wont save to a table though. If I use an entered value it does no problem.

    Anyone know how I can get round this?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Usually a bad idea to save calculated data, especially aggregate data. However, since prices can change over time, there is justification for saving the unit price value. If this is a bound form, no need for SQL action. Simply:

    Me!Price = Me.NameOfPriceControl

    Now calculate total price when needed.
    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.

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

Similar Threads

  1. Copying of a Form
    By Mahendra1000 in forum Access
    Replies: 2
    Last Post: 01-28-2014, 04:21 AM
  2. Copying info from one subform to another form
    By Stu Man Do in forum Forms
    Replies: 1
    Last Post: 04-03-2013, 04:27 PM
  3. Copying values from one form to another
    By mikethebass in forum Forms
    Replies: 2
    Last Post: 02-19-2012, 02:58 PM
  4. Help copying field values within a form
    By cshort64 in forum Programming
    Replies: 3
    Last Post: 11-11-2011, 01:07 PM
  5. Copying Access Form to a Word Doc
    By sxottwc in forum Forms
    Replies: 3
    Last Post: 07-16-2011, 06:19 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