+ Reply to Thread
Results 1 to 8 of 8

Doubleclick event interacting with Userform

  1. #1
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Doubleclick event interacting with Userform

    Have a userform with two option buttons (one delete and one insert), one textbox and an Ok and cancel button.

    In the worksheet module for one sheet I have a Private Sub Worksheet_BeforeDoubleClick event that will either insert or delete rows.

    How can I get the Private Sub Worksheet_BeforeDoubleClick event to interact with a userform?

    In the Private Sub Worksheet_BeforeDoubleClick event I put the line frmInsertDelete.show which shows the form and the default on the form is optDelete so in the event I also put if optInsert = True then goto Insertrows but this did not work.

    The textbox is for the user to enter how many rows the user wants to add.

    Any suggestions?
    Last edited by jeffreybrown; 02-13-2011 at 11:53 PM.
    HTH
    Regards, Jeff

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Doubleclick event interacting with Userform

    Hello Jeff,

    Have you set the UserForm's ShowModal property to False?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Doubleclick event interacting with Userform

    Hi Leith,

    No I did not change the ShowModal to False, but I have now. What happens now is I double click on a cell and the userform shows, but the macro still fires and inserts rows.

    What am I still missing?

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Doubleclick event interacting with Userform

    Hello Jeff,

    This will fix the problem.
    Please Login or Register  to view this content.

  5. #5
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Doubleclick event interacting with Userform

    Thanks again Leith for thecode, but it doesn't seem to want to work correctly as expected.

    At first I had...

    Please Login or Register  to view this content.
    ...so when the form opens optInsert is checked by default and it works, but then I doubleclick again to delete the rows just added and it still adds rows, no delete. I changed the UserForm_Initialize to optDelete = True and the delete works no matter whether I choose the Insert or Delete.

    I took the optInsert = True out of the UserForm_Initialize and no matter whether I choose the Insert or Delete nothing happens. I stepped through the code and sure enough both are false.

    Also, if I select Cancel on the form it still runs the doubleclick event.

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Doubleclick event interacting with Userform

    in the userform:

    Please Login or Register  to view this content.
    You should choose: use the UI of the worksheet or the userform.



  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Doubleclick event interacting with Userform

    Hi Leith,

    I believe I have figured on a solution. When the insert or delete button is clicked I can have that value stored to a cell such as the active sheet F1 and then in the code just reference that cell. I've tested this method and it works fine. When the code executes I will have the contents of F1 removed so the code is ready to run again.

    Hi snb,

    I will give this a go.

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Doubleclick event interacting with Userform

    Thanks again guys for all the help, I have a workable solution.

    For the Cancel button on the form I went with...

    Please Login or Register  to view this content.
    ...and it seems to do the trick.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1