hsingh1981
Programmer
Hi all,
I have this table which collects certain data table name "temp_KPIData".
I can open the table and copy the first row field to the excel sheet.
My code for this is this:
My question is how do i select certain rows depending on the id field and copy it to the excel sheet.
I have KPI_ID.....in (Temp_KPIData)
So basically if KPIId = 1 copy data to objSht.Cells(10, "I").Value
if KPIId = 24 copy data to objSht.Cells(15, "I").Value
and so on.....not sure how i do this?
many thanks
I have this table which collects certain data table name "temp_KPIData".
I can open the table and copy the first row field to the excel sheet.
My code for this is this:
Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Temp_KPIData", dbOpenSnapshot)
'Open a Excel and move to "source data sheet"
Dim objXL As Excel.Application
Dim objWkb As Workbook
Dim objSht As Worksheet
Set objXL = New Excel.Application
With objXL
.Workbooks.Open Me.txtExcelFileLocation
End With
objXL.Visible = True
Set objSht = objXL.Worksheets("KPI figures 1")
'Add the field names in row 1
objSht.Cells(10, "I").Value = rs.Fields("MaxAllowTarget")
objXL.Visible = True
objXL.UserControl = True
'Close the Database and Recordset
rs.Close
db.Close
'
My question is how do i select certain rows depending on the id field and copy it to the excel sheet.
I have KPI_ID.....in (Temp_KPIData)
So basically if KPIId = 1 copy data to objSht.Cells(10, "I").Value
if KPIId = 24 copy data to objSht.Cells(15, "I").Value
and so on.....not sure how i do this?
many thanks