Ronnie76
08-04-2008, 07:18 AM
Hello,
Pleasee take a look at the code beneath, it is written for Access and then I take a 'D-Tour' to Excel:
Dim dbs As Database
Dim rs As DAO.Recordset
Dim varItm As Variant
strDBName = "c:\invoicedata.mdb"
Set dbs = OpenDatabase(strDBName)
Set rst = CurrentDb.OpenRecordset("SELECT * FROM INVOICES where invoiceNumber = '" & invoiceNumber & "'")
'Set MyXLApp = New Excel.Application
'MyXLApp.Workbooks.Open Filename:="c:\test.xls"
Do While Not rst.EOF
MsgBox rst!Field1InvoiceNumber
MsgBox rst!Field2InvoiceRule
MsgBox rst!Field3InvoiceRuleTotal
rst.MoveNext
Loop
'MyXLApp.Quit 'Exit Excel
'Set MyXLApp = Nothing 'Remove object from memory
The problem:
I want the data in the loop to be placed in the Excel worksheet but I don't have no idea how.....
I supposte I have to take rst.size somehow and with this info I cant build a loop and wirte away the data from a specific cell in the Excel worksheet.
Does anyone has an example for me for this ?
Thanks !!
Pleasee take a look at the code beneath, it is written for Access and then I take a 'D-Tour' to Excel:
Dim dbs As Database
Dim rs As DAO.Recordset
Dim varItm As Variant
strDBName = "c:\invoicedata.mdb"
Set dbs = OpenDatabase(strDBName)
Set rst = CurrentDb.OpenRecordset("SELECT * FROM INVOICES where invoiceNumber = '" & invoiceNumber & "'")
'Set MyXLApp = New Excel.Application
'MyXLApp.Workbooks.Open Filename:="c:\test.xls"
Do While Not rst.EOF
MsgBox rst!Field1InvoiceNumber
MsgBox rst!Field2InvoiceRule
MsgBox rst!Field3InvoiceRuleTotal
rst.MoveNext
Loop
'MyXLApp.Quit 'Exit Excel
'Set MyXLApp = Nothing 'Remove object from memory
The problem:
I want the data in the loop to be placed in the Excel worksheet but I don't have no idea how.....
I supposte I have to take rst.size somehow and with this info I cant build a loop and wirte away the data from a specific cell in the Excel worksheet.
Does anyone has an example for me for this ?
Thanks !!