Results 1 to 6 of 6
  1. #1
    everterra is offline Novice
    Windows 8 Access 2013
    Join Date
    Apr 2014
    Location
    Gaia, Portugal
    Posts
    14

    How to make a field automatically receive the same value from another field?

    In Access 2013, in a table named DOCSDETAIL or form, I want the UTENTE (meaning user) field (Currency type €) automatically receives the same amount of PVP field (Currency type €) but can be modified as needed.


    Example: Registration of documents in which the amount paid by the USER has two possibilities;
    1. DifferS from PVP (Public Sale Price)
    2. Equal the PVP





    Looks like it might be used

    = "Update your_table set your_field_new = your_field_old"

    = "Update DOCSDETALHE set UTENTE = PVP"

    But do not know where to put and if the syntax is correct!
    Last edited by everterra; 04-22-2014 at 06:16 AM. Reason: misspelling

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I don't believe you can do this at the table level. If this is part of a form you can have in something like the ON EXIT property of PVP field have something like

    Code:
    if isnull(Utente) then
        utente = PVP
    endif
    Basically saying if there's no value in utente fill it in with whatever's in PVP otherwise leave it alone

  3. #3
    everterra is offline Novice
    Windows 8 Access 2013
    Join Date
    Apr 2014
    Location
    Gaia, Portugal
    Posts
    14
    Quote Originally Posted by rpeare View Post

    Basically saying if there's no value in utente fill it in with whatever's in PVP otherwise leave it alone

    This is a record of the medicines that I acquire and I want control what the retail value (PVP) and the amount I paid. I want to know the amount actually paid while verify that it is correct. The amount paid by the user (UTENTE ) if reimbursement is different, but if have not reimbursement is equal.

    Thus the value of PVP is never empty, nor the value of UTENTE is never empty. Sometimes the UTENTE value is equal to the PVP value, and other times is different.

    I found something like this;
    = "Update your_table set your_field_new = your_field_old"

    = "Update DOCSDETALHE set UTENTE = PVP"

    and with this;
    Me.field2 = Me.field1
    Me.VALUE = Me.PVP

    But donīt know how to put it to work and where.

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You haven't said anything about WHERE you are trying to do this.

    If it's on a table or query, I do not think it's possible to update a field other than by direct data entry, in other words if you update field A you can't adopt that same value in field B.

    if you are trying to do this operation on a form and the screenshot is part of a continuous form or subform in the ON EXIT property of PVP you can put in UTENTE = PVP this will overwrite anything in utente though even if there is a value there.

    If you are trying to do this as part of an update query you would have to be extremely careful to only update the records that were relevant.

    To do a BLANKET update of the UTENTE field with the value from the PVP field you'd have something like

    UPDATE tblTest SET UTENTE = PVP

    Again, be extremely careful about using this because it will overwrite EVERYTHING and you may not want it to.

  5. #5
    everterra is offline Novice
    Windows 8 Access 2013
    Join Date
    Apr 2014
    Location
    Gaia, Portugal
    Posts
    14
    Thanks for the help rpeare.

    As I said soon in the begining
    In Access 2013, in a table named DOCSDETAIL or form,...
    In a table or form (a subform datasheet type, more correctly) I want to enter a value in PVP field, but the UTENTEI field sometimes has the same value as the PVP field sometimes not. When the value is equal and for labor saving, I want the second field, called UTENTEI , just assume the same value as the previous one. Only when I verify the document I am registering has a lower value that corresponds to UTENTEI change it.


    Example:
    Product A costs € 15 (PVP field) but has a contribution, so the final amount payable is € 14 (UTENTE field).
    The product B costs €13 (PVP) but has no contribution and the final amount payable is € 13, then the UTENTE field gets the value of € 13.


    The idea is that the second field receive the same value as the first, a repeat, but it can be modified as needed, and where to get it, on the table or form (subform datasheet type, actually)?. What is the best solution?

  6. #6
    everterra is offline Novice
    Windows 8 Access 2013
    Join Date
    Apr 2014
    Location
    Gaia, Portugal
    Posts
    14
    I found the solution here:
    http://www.techonthenet.com/access/t...ter_update.php



    In the properties of field1, >Event, After update >in the button with 3 dots > Code Builder

    Put this code:

    Private Sub field1_AfterUpdate()

    If field1.Value <> "" Then
    Field2.Value = field1
    End If

    End Sub



    Thats it! Works!


    Thank you for the cooperation.

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

Similar Threads

  1. Replies: 2
    Last Post: 08-21-2013, 05:30 PM
  2. Replies: 1
    Last Post: 10-10-2012, 12:25 PM
  3. Replies: 5
    Last Post: 06-19-2012, 10:46 AM
  4. Replies: 2
    Last Post: 09-20-2010, 09:02 PM
  5. Replies: 4
    Last Post: 01-19-2010, 05:36 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