Results 1 to 5 of 5
  1. #1
    mkfloque is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    24

    VBA doesn't work after cutting & pasting controls onto a tab

    Hello All, I had a form with many "loose" controls. I attached VBA to some of these controls (VBA was working fine). Then, when i cut & pasted controls onto a new tab, the VBA for each control stopped working.

    Has anyone else had this problem?



    thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    the vba does NOT copy with the control (thanks Microsoft)
    you must copy/paste the vba afterwards, BUT if you copy the entire vba sub block,: like
    sub btn_click()
    code
    end sub

    then paste it all in the form, it will autmatically connect to the button, or combo, etc.

  3. #3
    mkfloque is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    24
    Thank you ranman!!!

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Two things to look for:

    First - When you cut-and-paste a control, its name often changes, but the VBA code does not get changed to match, so you have to either edit the VBA code to match the new name, or rename the control back to its old name (but see the next comment)

    Second, when you cut and paste a control, the Event properties (which are usually set to [Event Procedure] ) are cleared, but the code remains. If the control name is the same as it was, then resetting the event property to [Event procedure] will restore the link to the code.

  5. #5
    mkfloque is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    24
    John...resetting the event property worked perfectly (as the control names didn't change). Thx so much for the tip

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

Similar Threads

  1. Replies: 5
    Last Post: 04-14-2014, 12:37 PM
  2. Just doesn't seem to work!
    By txmmoore in forum Reports
    Replies: 9
    Last Post: 01-16-2014, 11:39 AM
  3. App doesn't work with runtime
    By bubba55 in forum Access
    Replies: 0
    Last Post: 09-21-2011, 08:33 AM
  4. Query doesn't work the day after
    By sithis876 in forum Queries
    Replies: 1
    Last Post: 07-13-2010, 07:11 AM
  5. Controls don't work on subforms
    By rscott7706 in forum Forms
    Replies: 8
    Last Post: 03-07-2010, 10:17 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