Results 1 to 7 of 7

Thread: vba access - refer to the control that was clicked

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    vba access - refer to the control that was clicked

    I've got a form with 72 text boxes, sorted in a 6*12 matrix. the text box names are Cell_[row number]_[Column number].

    I'd like that double clicking all the 72 text boxes will call the same function with the paramaters of the Cell's row number and column number.

    for example: the sub for cell_0_1 looks like:

    Private Sub Cell_0_1_DblClick(Cancel As Integer)
    Call OpenCell (me.cell_0_1)
    End Sub

    is there a way to work this out without writing 72 ugly sub routines?

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: vba access - refer to the control that was clicked

    No, there's no way around it. VBA doesn't support control arrays, so yo will need to write a _DblClick event for each one.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    Re: vba access - refer to the control that was clicked

    What about knowing which text box was click and to use it as the paramater for the function:

    Private Sub Cell_X_Y_DblClick(Cancel As Integer)
    Call OpenCell (me."the cell that was dblicked" )
    End Sub

  4. #4
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: vba access - refer to the control that was clicked

    If you want the code to execute on a Double Click of any/all the textboxes, then you will have to handle it seperately for each textbox.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    Re: vba access - refer to the control that was clicked

    Yes I got that, I just don't like the "call opencell (me.cell_X_Y)" part, which means I need to get all those 72 subroutines X's and Y's changed according to the cell that is double clicked.

    what I want to know is: how do you know which control was double clicked inside a dblick sub?

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    Re: vba access - refer to the control that was clicked

    anyone?

  7. #7
    Hyperactive Member nagasrikanth's Avatar
    Join Date
    Nov 2004
    Location
    India,Hyderabad.
    Posts
    420

    Re: vba access - refer to the control that was clicked

    as the "_" symbol is there... y can't we try for "INSTR","LEFT/RIGHT/MID" functions ????
    The Difference between a Successful person and others is not a Lack of Knowledge,
    But rather a Lack of WILL

Posting Permissions

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



Click Here to Expand Forum to Full Width