1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Access, How to Change an embedded Macro in a Button.

Discussion in 'Business Applications' started by ginaw, Sep 14, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. ginaw

    ginaw Thread Starter

    Joined:
    Sep 8, 2010
    Messages:
    81
    I created a button on my input form to duplicate record. This works fine but I want the record to duplicate and then clear the start date and end date for new entry. Does anyone know how I can do this?:confused:
     
  2. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    18,834
    Are you using a "Macro" or VBA code?
     
  3. ginaw

    ginaw Thread Starter

    Joined:
    Sep 8, 2010
    Messages:
    81
    OBP,

    I created a button with the button wizard that Duplicates the Record. It is a Macro. But if there is a better way in VBA than please let me know.
     
  4. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    18,834
    Normally the Button Wizard uses VBA code, which is why I asked, it is simple to add a bit of code on the end to clear the 2 fields.
     
  5. ginaw

    ginaw Thread Starter

    Joined:
    Sep 8, 2010
    Messages:
    81
    I have uploaded a snapshot of the embedded macro. Can you help me around this? Or should I add VBA code somewhere?
     

    Attached Files:

  6. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    18,834
    What is the name of the button?
    What are the actual names of the 2 fields that you want to clear?
     
  7. ginaw

    ginaw Thread Starter

    Joined:
    Sep 8, 2010
    Messages:
    81
    OBP,

    The name of the button is Duplicate Record. The 2 fields are DateStart and DateEnd.
     
  8. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    18,834
    Try this in the On Click Event Procedure
    On Error GoTo Err_Duplicate_Record_Click

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
    me.DateStart = ""
    me.dateEnd = ""

    Exit_Duplicate_Record_Click:
    Exit Sub

    Err_Duplicate_Record_Click:
    MsgBox Err.Description
    Resume Exit_Duplicate_Record_Click
     
  9. ginaw

    ginaw Thread Starter

    Joined:
    Sep 8, 2010
    Messages:
    81
    OBP,
    The Embedded Macro is on the 'On Click' event on the Duplicate Record Button.
     
  10. ginaw

    ginaw Thread Starter

    Joined:
    Sep 8, 2010
    Messages:
    81
    OBP,

    I replaced the macro with the code above and it worked!! You are awesome!! As always!!

    Thank you.
     
  11. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    18,834
    Sorry, I should of explained that you needed to replace the macro. Well done figuring it out.
     
  12. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1017667