A
anil
hi all
I am trying to calculate the Geometric Mean from the filtered data in
the subform(office 2000) in the text box in form.I am trying to
transfer the subform data into excel sheet and then using excel formula
to get GM.(as explained in book)I got this OLE automation code from
book:
Private Sub Form_Current()
Dim R As Recordset, X1 As Object
Set X1 = CreateObject("Excel.sheet.5")
Set R = Me.ExcelTestsubform.Form.RecordsetClone
pointer = 1
R.MoveFirst
Do Until R.EOF
X1.Cells(pointer, "A").Value = R.[Location]
R.MoveNext
pointer = pointer + 1
Loop
X1.Cells(pointer, "A").Formula = "=Geomean(A1:A" & pointer - 1 &
")"
Me.Geomean = X1.Cells(pointer, "A").Value
End Sub
But when I open the form I get the error "runtime error 13 type
mismatch" in line
'Set R = Me.ExcelTestsubform.Form.RecordsetClone'
Also it asks to declare pointer(which I declare variant later on) and
[Location] which is the field name and it do not recognise .
If this is wrong ,can you please recommend me other method.
thanks
anil
I am trying to calculate the Geometric Mean from the filtered data in
the subform(office 2000) in the text box in form.I am trying to
transfer the subform data into excel sheet and then using excel formula
to get GM.(as explained in book)I got this OLE automation code from
book:
Private Sub Form_Current()
Dim R As Recordset, X1 As Object
Set X1 = CreateObject("Excel.sheet.5")
Set R = Me.ExcelTestsubform.Form.RecordsetClone
pointer = 1
R.MoveFirst
Do Until R.EOF
X1.Cells(pointer, "A").Value = R.[Location]
R.MoveNext
pointer = pointer + 1
Loop
X1.Cells(pointer, "A").Formula = "=Geomean(A1:A" & pointer - 1 &
")"
Me.Geomean = X1.Cells(pointer, "A").Value
End Sub
But when I open the form I get the error "runtime error 13 type
mismatch" in line
'Set R = Me.ExcelTestsubform.Form.RecordsetClone'
Also it asks to declare pointer(which I declare variant later on) and
[Location] which is the field name and it do not recognise .
If this is wrong ,can you please recommend me other method.
thanks
anil