Type Mismatch - Help!

Maryanne

Registered User.
Local time
Today, 01:56
Joined
Jun 1, 2000
Messages
11
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.)
 
Chances are one of your fields in the me!...= statements after the BOF check are returning a null. If so, you cannot perform calculations with a null. Do some testing to see. Then perhaps use the Nz function to protect against nulls.
 
If the problem is on the Recordset line

Try,

Dim rst As DAO.Recordset

Instead of
Dim rst As Recordset

And make sure that "Microsoft DAO 3.6 Object Library" under Tools/References menu
 

Users who are viewing this thread

Back
Top Bottom