rookie7799
Programmer
Hi,
I encountered this weird problem ...
For some reason when I run the code below when going through records it skips the first one and shows the second one and so on???
This is what I have in Excel Sheet1:
A
1 666
2 555
3 444
4 333
So basically it skips 666 ??
Code:
Dim cnnExcel As ADODB.Connection, cnnExcel2 As ADODB.Connection, rstExcel As ADODB.Recordset, rst As ADODB.Recordset
Dim holidays(25) As String
Private Sub Form_Load()
strMainFilePath = "C:\Energy Metering\14-01.xls"
'"stand alone\Energy Metering Stand Alone.xls"
Set cnnExcel2 = New ADODB.Connection
Set rst = New ADODB.Recordset
With cnnExcel2
If .State = adStateOpen Then .Close
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Extended Properties").Value = "Excel 8.0"
.Open (strMainFilePath)
End With
rst.Open "Select * from [Sheet1$]", cnnExcel2, adOpenStatic, adLockOptimistic
rst.MoveFirst
Do Until rst.EOF
'Debug.Print rst.Fields(0)
holidays(Abs(rst.AbsolutePosition)) = rst.Fields(0)
rst.MoveNext
Loop
End Sub
ANY IDEAS ???
Thanks
I encountered this weird problem ...
For some reason when I run the code below when going through records it skips the first one and shows the second one and so on???
This is what I have in Excel Sheet1:
A
1 666
2 555
3 444
4 333
So basically it skips 666 ??
Code:
Dim cnnExcel As ADODB.Connection, cnnExcel2 As ADODB.Connection, rstExcel As ADODB.Recordset, rst As ADODB.Recordset
Dim holidays(25) As String
Private Sub Form_Load()
strMainFilePath = "C:\Energy Metering\14-01.xls"
'"stand alone\Energy Metering Stand Alone.xls"
Set cnnExcel2 = New ADODB.Connection
Set rst = New ADODB.Recordset
With cnnExcel2
If .State = adStateOpen Then .Close
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Extended Properties").Value = "Excel 8.0"
.Open (strMainFilePath)
End With
rst.Open "Select * from [Sheet1$]", cnnExcel2, adOpenStatic, adLockOptimistic
rst.MoveFirst
Do Until rst.EOF
'Debug.Print rst.Fields(0)
holidays(Abs(rst.AbsolutePosition)) = rst.Fields(0)
rst.MoveNext
Loop
End Sub
ANY IDEAS ???
Thanks