G
Guest
Greetings
I have a form and sunform and would like to calculate a control in the
subform. The subform displays records in a Datasheet view.
I place an unbound control on the subform and set its control source to do
the calculation. Some of the data required for the calculation is from a
table not in the form so I used the DLookUp function to get the external
data. So the control source look like this:
=DLookUp("[Fit0]","tblRmpsCoil","[CellNo]=" & Forms!frmTestRamp!Cell_No &
"And" & "[SeqNo]=" & Forms!frmTestRamp!Seq_No)*
This method works fine.
The actual calculation is a fourth order polynominal so the control source
gets rather long with lots of DLookUp's and is kinda bulky and slow. I need
to do some error checking as well
As an alternative I am trying to do the calculation in a procedure in the
subforms On Current event. Instead of DLookUp I create an ADO record set to
get the external data.
My problem is when I do the calculation and assign it to the unbound control
all the records have the same calculated value based on the current record.
As you move thru thre records all the calculated controls are the same and
based on the current record. The On Current event is as follows:
Private Sub Form_Current()
Dim CurCellNo As Integer
Dim CurSeqNo As Integer
Dim rsRmpsCoilPara As ADODB.Recordset
If CurCellNo <> [Forms]![frmTestRamp]![CellNo] Or CurSeqNo <>
[Forms]![frmTestRamp]![CellNo] Then
CurCellNo = [Forms]![frmTestRamp]![CellNo]
CurSeqNo = [Forms]![frmTestRamp]![SeqNo]
'Open Rmps Coil Pramaters Record Set
Set rsRmpsCoilPara = New ADODB.Recordset
With rsRmpsCoilPara
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockReadOnly
.Open "SELECT tblRmpsCoil.CellNo, tblRmpsCoil.SeqNo,
tblRmpsCoil.Alpha, tblRmpsCoil.Fit0, tblRmpsCoil.Fit2, tblRmpsCoil.Fit4 FROM
tblRmpsCoil WHERE tblRmpsCoil.CellNo = " & CurCellNo & " AND " &
"tblRmpsCoil.SeqNo= " & CurSeqNo, CurrentProject.Connection
.ActiveConnection = Nothing
End With
End If
'This is where the problem is
Text44 = * rsRmpsCoilPara!Fit0
End Sub
Where Text44 is the calculated controi, And is a field on the subform
used in the calculation
Am I using the wrong event or something.
Thanks for any help
Scott
I have a form and sunform and would like to calculate a control in the
subform. The subform displays records in a Datasheet view.
I place an unbound control on the subform and set its control source to do
the calculation. Some of the data required for the calculation is from a
table not in the form so I used the DLookUp function to get the external
data. So the control source look like this:
=DLookUp("[Fit0]","tblRmpsCoil","[CellNo]=" & Forms!frmTestRamp!Cell_No &
"And" & "[SeqNo]=" & Forms!frmTestRamp!Seq_No)*
This method works fine.
The actual calculation is a fourth order polynominal so the control source
gets rather long with lots of DLookUp's and is kinda bulky and slow. I need
to do some error checking as well
As an alternative I am trying to do the calculation in a procedure in the
subforms On Current event. Instead of DLookUp I create an ADO record set to
get the external data.
My problem is when I do the calculation and assign it to the unbound control
all the records have the same calculated value based on the current record.
As you move thru thre records all the calculated controls are the same and
based on the current record. The On Current event is as follows:
Private Sub Form_Current()
Dim CurCellNo As Integer
Dim CurSeqNo As Integer
Dim rsRmpsCoilPara As ADODB.Recordset
If CurCellNo <> [Forms]![frmTestRamp]![CellNo] Or CurSeqNo <>
[Forms]![frmTestRamp]![CellNo] Then
CurCellNo = [Forms]![frmTestRamp]![CellNo]
CurSeqNo = [Forms]![frmTestRamp]![SeqNo]
'Open Rmps Coil Pramaters Record Set
Set rsRmpsCoilPara = New ADODB.Recordset
With rsRmpsCoilPara
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockReadOnly
.Open "SELECT tblRmpsCoil.CellNo, tblRmpsCoil.SeqNo,
tblRmpsCoil.Alpha, tblRmpsCoil.Fit0, tblRmpsCoil.Fit2, tblRmpsCoil.Fit4 FROM
tblRmpsCoil WHERE tblRmpsCoil.CellNo = " & CurCellNo & " AND " &
"tblRmpsCoil.SeqNo= " & CurSeqNo, CurrentProject.Connection
.ActiveConnection = Nothing
End With
End If
'This is where the problem is
Text44 = * rsRmpsCoilPara!Fit0
End Sub
Where Text44 is the calculated controi, And is a field on the subform
used in the calculation
Am I using the wrong event or something.
Thanks for any help
Scott