Results 1 to 11 of 11
  1. #1
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152

    Button to copy fields then a button to paste them into another record.

    Hello.
    I have asked something like this previously. But I was merely looking as I was not upto the stage of incorporating it. I am now at that stage, but would like more clarity if anyone can help please.

    What do I need to do to be able to copy certain fields in one record via a copy butto and then go to another existing record and by clicking another button, Paste, will fill in the copied fields.



    I have different fields like:
    Survey Date - Which is a date selector.
    Surveyor - Which is a combo box.
    KitchenRenewYear - Which is a text box.

    If Someone was willing to start me off with how to do this then I can use the code for the remainder of the fileds I want to copy.

    This would be much appreciated.
    Thanks

  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
    Set up global variables for your values. In your copy button:

    VariableName = Me.TextboxName

    in the paste button

    Me.TextboxName = VariableName
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    maybe throw the vals into globals?

    Code:
    global val1
    global val2
    global val3
    
    button_event()
    
    val1 = me.control1
    val2 = me.control2
    val3 = me.control3
    now you have them in memory. get them whenever you want. right?

  4. #4
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152
    Quote Originally Posted by pbaldy View Post
    Set up global variables for your values. In your copy button:

    VariableName = Me.TextboxName

    in the paste button

    Me.TextboxName = VariableName
    So is this just a case of creating a button and adding all the Fields I want to copy as:
    VariableName = Me.TextboxName
    and visaversa for paste button?

    Or is there some code for stating copy?
    I.e
    Code:
    Private Sub btnCopy_Click()
    DoCmd.RunCommand acCmdCopy
    VarSurveyor = Me.cboSurveyor
    VarSurveyDate = Me.txtSurveyDate
    End Sub

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    For what you've described, there's no built in function. You'll need to create and code both buttons.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152
    Quote Originally Posted by pbaldy View Post
    For what you've described, there's no built in function. You'll need to create and code both buttons.
    Sorry but I am out of my depth with this one.
    Where and how would I start?

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Declare your variables either in a standard module or the top of the form's module, depending on whether you want them available outside this form. Create buttons and add the code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152
    Quote Originally Posted by pbaldy View Post
    Declare your variables either in a standard module or the top of the form's module, depending on whether you want them available outside this form. Create buttons and add the code.
    Sorry I dont understand what is meant by declaring the variables?
    I.e. How would I declare the following:
    1) Survey Date - Which is a date selector.
    2) Surveyor - Which is a combo box.
    3) KitchenRenewYear - Which is a text box.

  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
    Why don't you look up "variables" in VBA help? There's a lot more info there than I can type here.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by pbaldy View Post
    Why don't you look up "variables" in VBA help?
    LOL! Because even semi-newbie's haven't reached 100% productivity.

    Sorry, had to. Woohooo, Paul! Nice one.

  11. #11
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    DECLARE means, in code:
    Code:
    DIM variableNameHere AS dataTypeNameHere
    CAP words are literal/verbatim. Proper case words to be replaced by your own.

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

Similar Threads

  1. Replies: 2
    Last Post: 06-06-2011, 04:18 PM
  2. Copy/paste to new record.
    By xbox1513 in forum Forms
    Replies: 1
    Last Post: 02-23-2011, 04:52 PM
  3. Copy / Paste some fields
    By isnpms in forum Access
    Replies: 2
    Last Post: 08-25-2010, 10:13 AM
  4. Copy / Paste some fields
    By isnpms in forum Import/Export Data
    Replies: 1
    Last Post: 08-25-2010, 07:48 AM
  5. Replies: 1
    Last Post: 07-27-2010, 02:27 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