Avatar of Bob Schneider
Bob Schneider
Flag for United States of America asked on

Passing an Array Dimension to Sub

I want to pass an array dimension via a parameter.  I want a single sub to work with calls in which the array dimension will change.  I get a "constant expression required" error when I try to call this:
rivate Sub SingleRcrd(ByRef iArrayBound As Integer, ByVal ThisSql As String)
    'On Error GoTo ErrorHandler
    
    Dim rs As ADODB.Recordset
    Dim i As Integer
    Dim UploadArr(iArrayBound)
    
    Set rs = New ADODB.Recordset
    rs.Open ThisSql, conn, 1, 2
    For i = 0 To iArrayBound
        UploadArr(i) = rs(i).Value
    Next i
    rs.Close
    Set rs = Nothing
    
    Set rs = New ADODB.Recordset
    rs.Open ThisSql, srvr_conn, 1, 2
    For i = 0 To iArrayBound
        rs(i).Value = UploadArr(i)
    Next i
    rs.Update
    rs.Close
    Set rs = Nothing
    
    Exit Sub
ErrorHandler:
    Beep
    ErrorHandler
End Sub

Open in new window


with this:
    sql = "SELECT EventName, EventDate, Club, Website, Weather, Comments, FeeIncrDate, TimingMethod, EventDirID, ShowOnline, "
    sql = sql & "OnlineReg, WhenShutdown, FeeIncrDate FROM Events WHERE EventID = " & lEventID
    Call SingleRcrd(12, sql)

Open in new window


What am I doing wrong?
Visual Basic ClassicMicrosoft SQL Server

Avatar of undefined
Last Comment
Bob Schneider

8/22/2022 - Mon
SOLUTION
Paul Jackson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Banthor

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
advfinance

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Bob Schneider

ASKER
Thanks a bunch!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck