Results 1 to 9 of 9
  1. #1
    anandram is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    27

    Unhappy Copy field from form to another field in same form

    Howdy,

    So i searched a little but could not understand so would appreciate some help.

    I have four text boxes field in my form, say fielda,fieldb,fieldc,fieldd,

    I want to copy the above four field's values, into:

    fielde, fieldf, fieldg, fieldh respectively (field a > field e, field b to field f etc)

    Is there a button which i can code which will allow the user to do this as some "deciding" needs to be made prior to the fields being copied and pasted. (ie: afterupdate is not ideal, onclick would be good)





    Ideally it'd be good if the button copies fields a to d and dumps them into the seperate fields e to h with one button click.

    Thanks for the help,

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The code would look like:

    Me.TextboxE = Me.TextboxA
    Me.TextboxF = Me.TextboxB
    ...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    anandram is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    27
    Quote Originally Posted by pbaldy View Post
    The code would look like:

    Me.TextboxE = Me.TextboxA
    Me.TextboxF = Me.TextboxB
    ...
    Thanks, funnily enough you had responded to the other guy whos thread i looked up, but i wasnt sure regarding your response (didnt understand)

    So i would create one button, use the above code (relative to my txt boc names) and this would both copy and paste into the required fields?

    What is telling access to copy and paste in the above code?

    Could you please elaborate? Thanks for the help.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You want to use the appropriate form reference:

    Forms Refer to Form and Subform properties and controls

    The syntax for the copy is basically:

    Destination = Source

    so in my first line above the contents of the textbox named "TextboxA" would be copied to the textbox named "TextboxE". I used "Me" since from your description they are all on the same form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    anandram is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    27
    Hi thanks for the explanation.

    I think i need to back up a bit.

    I think i understand what the code is doing however i am not sure what to put where.

    I create a button, i open vba code for onclick, then i simply put your code in above? I am sure there is more to it than that as what i have just outlined doesnt seem correct..?

    I was just looking at your previous thread to the other guy and was looking into variables etc, however this didnt quite work out either. I understand the concept but executing it is different. Anyway, appreciate if you could further dumb it down for me.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The code should be as simple as that, with the appropriate names of course. If you don't know where to put the code:

    http://www.baldyweb.com/FirstVBA.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    anandram is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    27
    Hi, thanks I will try the code inside the button. Hopefully it will copy and paste the required field correctly. I will get back to you. Thanks for your help.

  8. #8
    anandram is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    27
    Thanks for your help, this worked fine

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'm glad it worked for you.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 7
    Last Post: 01-12-2011, 08:59 AM
  2. Replies: 9
    Last Post: 12-15-2010, 01:44 PM
  3. Replies: 1
    Last Post: 11-13-2010, 12:57 PM
  4. Replies: 3
    Last Post: 11-05-2010, 03:10 PM
  5. Copy form field to another table
    By Dega in forum Forms
    Replies: 6
    Last Post: 05-21-2010, 02:57 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