This is my intro to programming and the programmer at work who has been graciously helping me is on vacation. I am trying to program a subform to automatically set certain fields based on the criteria in the main form or earlier records of the subform. I made the changes my programming friend suggested and get 'Type Mismatch' error message.
Private Sub Form_Current()
Dim rst As Recordset
' Create a clone of current recordset and place at current record
Set rst = Me.RecordsetClone
rst.MoveFirst
varBookmark = Me.Bookmark
rst.Bookmark = varBookmark
rst.MovePrevious
' If the previous record is the first record then fetch initial rate from main form
If rst.BOF = True Then
Me![New Shop Rate Portion] = Forms![Escalation Form].[Initial Labour Portion] * (1 + (([Adjusted Shop Rate] / [Preceding Shop Rate] - 1) * 1))
Me![New Parts Portion Rate] = Forms![Escalation Form].[Initial Materials Portion] * (((1 + ([Preceding Parts Rate] / 100)) * ((1 + [Adjusted Parts Rate] / 100)) - 1 * 100))
Else
' otherwise fetch previous records value
Me![Preceding Shop Rate] = rst![Preceding Shop Rate]
End If
rst.Close
End Sub
Any ideas?
The calculations all worked before, but I had to do a lot of manual data entry (and risk human error.)
Private Sub Form_Current()
Dim rst As Recordset
' Create a clone of current recordset and place at current record
Set rst = Me.RecordsetClone
rst.MoveFirst
varBookmark = Me.Bookmark
rst.Bookmark = varBookmark
rst.MovePrevious
' If the previous record is the first record then fetch initial rate from main form
If rst.BOF = True Then
Me![New Shop Rate Portion] = Forms![Escalation Form].[Initial Labour Portion] * (1 + (([Adjusted Shop Rate] / [Preceding Shop Rate] - 1) * 1))
Me![New Parts Portion Rate] = Forms![Escalation Form].[Initial Materials Portion] * (((1 + ([Preceding Parts Rate] / 100)) * ((1 + [Adjusted Parts Rate] / 100)) - 1 * 100))
Else
' otherwise fetch previous records value
Me![Preceding Shop Rate] = rst![Preceding Shop Rate]
End If
rst.Close
End Sub
Any ideas?
The calculations all worked before, but I had to do a lot of manual data entry (and risk human error.)