Consulting

Results 1 to 3 of 3

Thread: ByRef Array Button Click

  1. #1
    VBAX Regular
    Joined
    Aug 2016
    Posts
    13
    Location

    ByRef Array Button Click

    Hi,

    I am trying to pass an array generated on one button click to a subroutine button click. For example

    Private Sub Retrieve_Attendance_click(ByRef LArrayDatesOfPay() As String)Dim todays_date_from As Variant
    Dim todays_date_to As Variant
    Dim rowNumSubmit As Range
    'Dim LArrayDatesOfPay() As String
    Dim txtB1 As Control
    Dim myrow_10() As Integer
    'Main.Hide
    'Submit_Wages.Retrieve_Attendance.Visible = False
    Call PopulateArrayEmployed
    todays_date_from = Me.Date_Picker_Wages_Start_Date.Value
    todays_date_to = Me.Date_Picker_Wages_End_Date.Value
    x = 1
    
    
    For Each rowNumSubmit In ThisWorkbook.Worksheets("Input Take Sheet").Range("Input_take_table[Date]").Rows
        ReDim Preserve myrow_10(x)
        myrow_10(x) = rowNumSubmit.row - 1
     If ThisWorkbook.Worksheets("Input Take Sheet").Range("Input_take_table[Date]").Rows(myrow_10(x)).Value >= todays_date_from _
        And ThisWorkbook.Worksheets("Input Take Sheet").Range("Input_take_table[Date]").Rows(myrow_10(x)).Value <= todays_date_to Then
        
        ReDim Preserve LArrayDatesOfPay(x)
        LArrayDatesOfPay(x) = ThisWorkbook.Worksheets("Input Take Sheet").Range("Input_take_table[Date]").Rows(myrow_10(x)).Value
    
    
        x = x + 1
        
        End If
        
    Next

    and then

    Private Sub Wages_Submit_Click()Dim LArrayDatesOfPay() As Date
    
    
    Call Retrieve_Attendance_click(LArrayDatesOfPay)
    MsgBox UBound(LArrayDatesOfPay)
    
    
    End Sub

    But it keeps coming up with a compile error Procedure declaration does not match description of event or procedure having the same name error.

    Any help would be greatly appreciated.

    Kind Regards

  2. #2
    Cross posted on multiple sites

    please read this http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    +1 on cross posting

    Click events have a 'fixed' definition and you can't just change them to pass a parameter

    I'd save it in a Public variable in one sub and then use it in the second
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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