LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VB6 Expected Array error


Hello all!
I am a newbie VB6 programmer.
This part of my program is going to the SQL server to get data and then
taking that data and entering it into an Excel spreadsheet. (Excel 2003)
I am getting an "expected array" compile error on this line:
objWorkSheet.Cells(Row, 1) = rsData("MachineNum")

Thanks in advance for any insight into my problem(s).

Here is my code:

Private Sub cmdrunreport_Click()
Dim SQLdb1 As New Connection
Set SQLdb1 = New Connection
dDate1 = txtdDate1.Text
dDate2 = txtdDate2.Text
Dim objExcel As Excel.Application
Dim objWorkBook As Excel.Workbook
Dim objWorkSheet As Excel.Worksheet
Dim rsData As String
Dim Row As Long
Row = 0


'Open Excel file
Set objExcel = New Excel.Application
Set objWorkBook =
objExcel.Workbooks.Open("S:\Assembly\Bondline\SGWB L.xls")
Set objWorkSheet = objWorkBook.Worksheets(1)

'Retrieve the data from sqlserver
SQLdb1.Open "Data Source=probe-srv1;Initial Catalog=Assembly;User
ID=bpotoeski;password=brian;Persist Security Info=False"
rsData = "SELECT MachineNum, dDate, BondLine FROM SGWBL; " & _
"WHERE dDate Between 'dDate1' AND 'dDate2'"
MsgBox " I have the data"

'loop through the data
Do Until EOF(rsData)


'increment row number
Row = Row + 1

'write data to worksheet
objWorkSheet.Cells(Row, 1) = rsData("MachineNum")<--ERROR
objWorkSheet.Cells(Row, 2) = rsData("dDate")
objWorkSheet.Cells(Row, 3) = rsData("BondLine")

rsData.MoveNext


'Save and close file
objWorkBook.Save
objWorkBook.Close

'cleanup
Set objWorkSheet = Nothing
Set objWorkBook = Nothing
Set objExcel = Nothing

'close the database
SQLdb1.Close

End Sub

*** Sent via Developersdex http://www.developersdex.com ***
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ReDim not working as expected. Array expert needed. MichaelDavid Excel Programming 15 February 10th 09 10:39 PM
Compile Error: Expected Array BEEJAY Excel Programming 7 December 8th 08 08:23 PM
Expected end of statement error Patrick C. Simonds Excel Programming 1 August 14th 08 08:28 PM
compile error - expected an array John Excel Programming 8 September 21st 06 08:04 PM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM


All times are GMT +1. The time now is 11:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"