I have a database (access 2k) of filenames, version, and path, that I need to test for on each PC I support. so I loaded the SQL results into rsRequired. I then, using someones example put in the following sub:
Sub GetRequired
Dim lngCounter
Dim rsRequired
Dim cnMSOffice
' Create the connection object and connection string, then open the connection
Set cnMSOffice = CreateObject("ADODB.Connection"
cnMSOffice.ConnectionString = "provider=Microsoft.JET.OLEDB.4.0;User ID=Admin;Data Source=\\njwarfs7\sms_pkg$\utils\MSOff2000.mdb"
cnMSOffice.Open
'create the recordset object
Set rsRequired = cnMSOffice.Execute("SELECT FILES.FILE_NAME, FILES.VERSION, FILES.PATH, FILES.REQUIREDID FROM REQUIRED INNER JOIN FILES ON REQUIRED.ID = FILES.REQUIREDID WHERE (((REQUIRED.REQUIRED)=Yes));"
'code ok to here
ReDim astrFileList(version,0)
lngCounter = 0
Do While Not rsRequired.EOF
ReDim Preserve astrPhoneList(version, lngCounter)
astrFileList(version, lngCounter) = rsRequired.Fields("VERSION".Value
astrFileList(file_name, lngCounter) = rsRequired.Fields("FILE_NAME".Value
astrFileList(path, lngCounter) = rsRequired.Fields("PATH".Value
lngCounter = lngCounter + 1
rsRequired.MoveNext
Loop
End Sub
The error I'm getting is "subscript out of range" at the first loading line (astrFileList(version, lngCounter) = rsRequired.Fields("VERSION".Value) the value is 1.
I'm guessing that the "ReDim astrFileList(version,0)" the second parameter is how many records, am I right? IF so, then when I try the second set, the "subscript" error will pop up becuase I have only allowed for 0. What if I dont know how many there will be?
Any help would be great - this is the first time I've ever written anything like this.
-Jim Connors
Sub GetRequired
Dim lngCounter
Dim rsRequired
Dim cnMSOffice
' Create the connection object and connection string, then open the connection
Set cnMSOffice = CreateObject("ADODB.Connection"
cnMSOffice.ConnectionString = "provider=Microsoft.JET.OLEDB.4.0;User ID=Admin;Data Source=\\njwarfs7\sms_pkg$\utils\MSOff2000.mdb"
cnMSOffice.Open
'create the recordset object
Set rsRequired = cnMSOffice.Execute("SELECT FILES.FILE_NAME, FILES.VERSION, FILES.PATH, FILES.REQUIREDID FROM REQUIRED INNER JOIN FILES ON REQUIRED.ID = FILES.REQUIREDID WHERE (((REQUIRED.REQUIRED)=Yes));"
'code ok to here
ReDim astrFileList(version,0)
lngCounter = 0
Do While Not rsRequired.EOF
ReDim Preserve astrPhoneList(version, lngCounter)
astrFileList(version, lngCounter) = rsRequired.Fields("VERSION".Value
astrFileList(file_name, lngCounter) = rsRequired.Fields("FILE_NAME".Value
astrFileList(path, lngCounter) = rsRequired.Fields("PATH".Value
lngCounter = lngCounter + 1
rsRequired.MoveNext
Loop
End Sub
The error I'm getting is "subscript out of range" at the first loading line (astrFileList(version, lngCounter) = rsRequired.Fields("VERSION".Value) the value is 1.
I'm guessing that the "ReDim astrFileList(version,0)" the second parameter is how many records, am I right? IF so, then when I try the second set, the "subscript" error will pop up becuase I have only allowed for 0. What if I dont know how many there will be?
Any help would be great - this is the first time I've ever written anything like this.
-Jim Connors