M
Maria
Hi there!
I have some problems with moving data from form to
exceldocument. I have the following code, but I get the
errormessage "To few parameters, expected 2." Does anyone
of you know what's wrong? Please help me if you can!!!
Private Sub ExcelKnp_Click()
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Application.Visible = True
Set ExcelBook = ExcelApp.Workbooks.Add
ExcelBook.Worksheets(1).Cells(1, 1).Font.Size = 10
ExcelBook.Worksheets(1).Cells(1, 1).Font.Bold = True
ExcelBook.Worksheets(1).Cells(1, 1).Value = "e2upnr"
ExcelBook.Worksheets(1).Cells(1, 2).Font.Size = 10
ExcelBook.Worksheets(1).Cells(1, 2).Font.Bold = True
ExcelBook.Worksheets(1).Cells(1, 2).Value = "e3vgnr"
Set oRS = CreateObject("ADODB.RecordSet")
Set oConn = CreateObject("ADODB.Connection")
oConn.ConnectionString = "DRIVER={Microsoft Access
Driver (*.mdb)}; DBQ=C:\M\MM.mdb"
bSucess = oConn.Open
Dim q
q = " SELECT Forms!AktUpn!e2upnr, Forms!AktUpn!
AktUpnUnd!e3vgnr"
Dim i
i = 2
Set oRS = oConn.Execute(q)
Do While Not oRS.EOF
ExcelBook.Worksheets(1).Cells(i, 1).Value = oRS
("e2upnr")
ExcelBook.Worksheets(1).Cells(i, 2).Value = oRS
("e3vgnr")
oRS.MoveNext
i = i + 1
Loop
Set oRS = Nothing
bSucsess = oConn.Close
Set oConn = Nothing
ExcelBook.SaveAs "C:/Majsan.xls"
ExcelApp.Application.Quit
Set ExcelApp = Nothing
End Sub
Cheers!
I have some problems with moving data from form to
exceldocument. I have the following code, but I get the
errormessage "To few parameters, expected 2." Does anyone
of you know what's wrong? Please help me if you can!!!
Private Sub ExcelKnp_Click()
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Application.Visible = True
Set ExcelBook = ExcelApp.Workbooks.Add
ExcelBook.Worksheets(1).Cells(1, 1).Font.Size = 10
ExcelBook.Worksheets(1).Cells(1, 1).Font.Bold = True
ExcelBook.Worksheets(1).Cells(1, 1).Value = "e2upnr"
ExcelBook.Worksheets(1).Cells(1, 2).Font.Size = 10
ExcelBook.Worksheets(1).Cells(1, 2).Font.Bold = True
ExcelBook.Worksheets(1).Cells(1, 2).Value = "e3vgnr"
Set oRS = CreateObject("ADODB.RecordSet")
Set oConn = CreateObject("ADODB.Connection")
oConn.ConnectionString = "DRIVER={Microsoft Access
Driver (*.mdb)}; DBQ=C:\M\MM.mdb"
bSucess = oConn.Open
Dim q
q = " SELECT Forms!AktUpn!e2upnr, Forms!AktUpn!
AktUpnUnd!e3vgnr"
Dim i
i = 2
Set oRS = oConn.Execute(q)
Do While Not oRS.EOF
ExcelBook.Worksheets(1).Cells(i, 1).Value = oRS
("e2upnr")
ExcelBook.Worksheets(1).Cells(i, 2).Value = oRS
("e3vgnr")
oRS.MoveNext
i = i + 1
Loop
Set oRS = Nothing
bSucsess = oConn.Close
Set oConn = Nothing
ExcelBook.SaveAs "C:/Majsan.xls"
ExcelApp.Application.Quit
Set ExcelApp = Nothing
End Sub
Cheers!