Hello new to this forum:
When I 'Catch' the CatchCWO, CatchRWO, CatchCost, CatchRate as noted below I get:
CatchCWO: 60001548 (All the Work Orders associated to the above - PERFECT!)
CatchRWO: Exact match to the above - PERFECT!
CatchCost: Jan160001548 (A static date associated to the field name - What the Heck! It should be the value...)
CatchRate: Jan1 (... same)
Vxy = Round((CatchRate * CatchCost), 2): Type Mismatch - rrrrrr!
I have a headache! Why will it not CatchCost or CatchRate ? When I Manually enter the column name !Jan1 it updates Jan1 - cool. But because its dynamically populating the column/field name using 'Fieldn' I use "!" & Fieldn & " it craps out - why why whyI need a fresh pair of eyes... Please and thanks!
Here is the code:
For Each SearchAcsFieldNameStartDate In db.TableDefs("" & OpMatchCostTbl & "").Fields
Debug.Print SearchAcsFieldNameStartDate.Name
Fieldn = SearchAcsFieldNameStartDate.Name
For lngPosition = LBound(strDaily) To UBound(strDaily)
If Fieldn = strDaily(lngPosition) Then
Dim rstOpMatchCostTbl As Recordset
Set rstOpMatchCostTbl = db.OpenRecordset("SELECT LOrder, " & Fieldn & " FROM " & OpMatchCostTbl & "", dbOpenDynaset)
With rstOpMatchCostTbl
Do While True
CatchCWO = !LOrder
CatchCost = !["Fieldn"]
'CatchCost = 500
Dim rstOpMatchRateTbl As Recordset
Set rstOpMatchRateTbl = db.OpenRecordset("SELECT Order, " & Fieldn & " FROM " & OpMatchRateTbl & "", dbOpenDynaset)
With rstOpMatchRateTbl
Do While True
CatchRWO = !Order
'CatchRate = Fieldn
CatchRate = 0.14
If CatchCWO = CatchRWO Then
If CatchRate <= "0" Then
Vxy = "0"
Else
'Update Result Table
Vxy = Round((CatchCost * CatchRate), 2)
db.Execute "UPDATE TestingAdeResults " _
& "SET " & Fieldn & " = '" & Vxy & "'" _
& "WHERE LOrder = '" & CatchRWO & "';"
End If
GoTo Err2:
Else
GoTo Err1:
End If
Err1:
.MoveNext
If .EOF Then Exit Do
Loop
.Close
End With
Err2:
.MoveNext
If .EOF Then Exit Do
Loop
End With
End If
Next lngPosition
Next
Any help is much appreciated thanks!