Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jun 2004
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Procedure Call (VBA)

    I have a value that is set by the current week number.
    Me.txtCurWk = DatePart("ww", Now()) - 1
    This value is returned as 37.
    I want to call a sub procedure that is named lblWK(me.txtcurWk)_click.
    I have a label for each week of the year. And depending on which week it is, that is the week i want to load. Thanks for you help

    Nick

    Private Sub lblWK10_Click()

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Procedure Call (VBA)

    You can't quite do it that way. Wouldn't it be more user-friendly to have a list box or combo box from which the user can select a week? 52 or 53 labels is quite a lot.

    If you want to keep the labels, you can do something like this:

    Private Sub lblWk1_Click()
    HandleWeek 1
    End Sub

    ...

    Private Sub lblWeek53_Click()
    HandleWeek 53
    End Sub

    Private Sub HandleWeek(intWeek As Integer)
    ' code to do something with the week number
    ' goes here
    End Sub

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Procedure Call (VBA)

    You have 52 labels on your form and you want to make one of them visible and the others hidden? Or... I'm not quite sure what you mean by "load."

  4. #4
    2 Star Lounger
    Join Date
    Jun 2004
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Procedure Call (VBA)

    I have a calendar of the entire year. When a person clicks on the week number or particular date, a form is pulled up of the respective date. Each form is pulled up by executing a on click procedure, lblWK(##)_click. Where the ## is the week number. I was wanting to know if it is possible to have a statement to call the on click procedure of the correct week. Cause i get the current week as mentioned above.

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Procedure Call (VBA)

    Procedure names can't have variables in them. Try the approach HansV posted, where you have a separate click procedure for each clickable label, and pass the week number to the second procedure.

Posting Permissions

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