Results 1 to 6 of 6
  1. #1
    usselite is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    5

    Textbox calculated value to table

    Hello,

    I got a textbox in a form which does calculate for me. Calculation works fine but now I need to write it away in a table. I use access 2010 and I am aware that the function calculation exist. But my calculation uses multiple tables so that is not going to work I suppose.

    The textbox with value is named = 'totaal_prijs' and it needs to be written away in the table 'Bestelling' and in field 'totaal_prijs'.



    This didn't seem to work:
    Code:
    CurrentDb.Execute "UPDATE Bestelling SET (totaal_prijs) Values ('"& Me.totaal_prijs &"')"
    or

    Code:
    Me!totaal_prijs = Me!Bestelling.Column(4)
    All are applied at the after update from the Form.

    Edit:
    This code works 1/2 but it updates ALL records. How can I make it update only the record from the form which is opened. And that I don't need to use an button?
    Code:
    docmd.setwarnings false
    docmd.runsql "UPDATE Bestelling SET Bestelling.totaal_prijs = " & Forms!Bestelling!totaal_prijs
    docmd.setwarnings true

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Are you sure about saving this value to a table. It is not normally considered to be good practice to save calculations. Usually better to do the calculation again when/wherever required in case the data used changes.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Use a WHERE clause in the SQL statement.

    If totaal_prijs is a field of the form's RecordSource, this should work

    Me!totaal_prijs = Me.Bestelling.Column(4)
    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.

  4. #4
    usselite is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    5
    Yes Bob Fitz, I am sure.

    Quote Originally Posted by June7 View Post
    Use a WHERE clause in the SQL statement.

    If totaal_prijs is a field of the form's RecordSource, this should work

    Me!totaal_prijs = Me.Bestelling.Column(4)
    I have tried it again but it really doesn't want work somehow. It does not give me any error at all. I applied it at after update from the form and tried it on the textbox with the value.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Want to provide project for analysis? Follow instructions at bottom of my post.
    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.

  6. #6
    TG_W is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2010
    Location
    Manvel, TX
    Posts
    299
    Have you thought about using an update query that kicks off after closing the form and/or with a button?

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

Similar Threads

  1. Calculated field for table not form
    By cheyanne in forum Access
    Replies: 1
    Last Post: 01-27-2012, 07:29 AM
  2. calculated fields appearing in table
    By jamhome in forum Access
    Replies: 16
    Last Post: 07-19-2011, 02:57 PM
  3. Replies: 4
    Last Post: 06-29-2011, 06:32 AM
  4. Calculated date does not show in table
    By frankq in forum Forms
    Replies: 6
    Last Post: 06-23-2011, 01:31 AM
  5. Calculated Text Box Populating in Table
    By Debbie in forum Access
    Replies: 2
    Last Post: 11-13-2006, 08:02 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