Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2008
    Posts
    20

    Smile Unanswered: Duplicate text boxes

    I have a form in add mode and I have 2 text boxes named “Cash” and “Cash2”. I wish that every time I fill a new record, the system automatically fills the text box “Cash2” with the previous-record amount written in “Cash”. How can I do this? Thanks

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    have a look at the dlookup function
    however you will need a guaranteed way of identifying what is the previous record

    you may need to put it in a function and call that function from the forms on current event, and any other appropriate events
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    It's really easy actually.

    All you need to do is put in the following code in your After Update event procedure for the form:

    Me.Cash2.DefaultValue = Nz(Me.Cash,0)

    Done.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    Sep 2008
    Posts
    20
    Hi Startrekker, i tried you method but unfortunately, after i did everything you mentioned, the vba is poping this "Method of data member not found" on the defultvalut. What am i doing wrong?

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Check the names of your controls. The code I gave you relies on Cash2 and Cash being there.

    Oh and the first record won't give you the "previous" entry. It will only work after the first record is entered.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  6. #6
    Join Date
    Sep 2008
    Posts
    20
    Yap, this time it worked but... its not what im trying to seek... some time ago i found this example of the net and it is exactly what i want:

    http://www.speedyshare.com/836837489.html

    in this sample database there is this form with the field names "ID and Color". when you fill data in the color column, the next record automatically updates what you have written in the previous record.

    Now, I have added a new field name named "Color2". Can anybody can edit the vba code and instead the auto update fills the next colorrecord, fills the "color2" record instead?

    Thanks guys

  7. #7
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Most of us are quite reluctant to do your work for you. Why not try to understand the VBA code and make the changes yourself?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  8. #8
    Join Date
    Sep 2008
    Posts
    20
    Its because im in a hurry but thanks for the morale cos successfully i did it

  9. #9
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Way to go!

    Everyone's in a hurry
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •