Preface: Although I have found other questions and answers on either part of this error message separately (i.e. Run-time error '13' = Type Mismatch OR'No Current Record' is mostly associated with error '3021'), I have not found the combination of these two parts of the error message and a corresponding answer to this issue.
I have an access UI that is connected to a MSSQL database. I have not made any changes to the Access UI nor to the database for at least 18 months and things have been working and running without any errors. This error has never come up until just now.
I have reverted back to a previous version of Access but that did not fix the error message.
This is (part of) the code that is causing the error with the arrows pointing where the debugger says the issue is:
If Not IsNull(Me.cbIngredient) Then
Set rs = CurrentDb().OpenRecordset("Select * from Recipes where PrepId = " & Me.Id & " and IngredientID = " & Me.cbIngredient, dbOpenDynaset, dbSeeChanges)
If rs.RecordCount = 1 Then
Set rs = Nothing
MsgBox "You already added this ingredient!"
Exit Sub
End If
Set rs = CurrentDb.OpenRecordset("Select u.id, u.uom from ingredients as i inner join uoms as u on i.uom = u.id where i.Id = " & Me.cbIngredient, dbOpenDynaset, dbSeeChanges)
rs.MoveLast
baseUomId = rs.Fields(0)
baseUom = rs.Fields(1)
If Me.Uom <> baseUomId Then
Set rs = CurrentDb.OpenRecordset("Select MasterId from uoms where Id = " & Me.Uom, dbOpenDynaset, dbSeeChanges)
rs.MoveLast
If IsNull(rs.Fields(0)) Or rs.Fields(0) <> baseUomId Then
Set rs = Nothing
MsgBox "Uom should be compatible with " & baseUom
Exit Sub
End If
End If
Else
Set rs = CurrentDb().OpenRecordset("Select * from Recipes where MenuId = " & Me.Id & " and PrepID = " & Me.PrepId, dbOpenDynaset, dbSeeChanges)
If rs.RecordCount = 1 Then
Set rs = Nothing
MsgBox "You already added this prep!"
Exit Sub
End If
End If
Set rs = CurrentDb().OpenRecordset("Recipes", dbOpenDynaset, dbSeeChanges)
rs.AddNew
rs.Fields(1) = Me.IngredientType
rs.Fields(2) = Me.Id
rs.Fields(3) = Me.cbIngredient
rs.Fields(4) = Me.PrepId
>>rs.Fields(5) = Me.Quantity
rs.Fields(6) = Me.Uom
rs.Update
rs.MoveLast
Me.RecipesForm.Requery
Me.cbIngredient = Null
Me.Quantity = Null
Me.PrepId = Null
Me.Uom = Null
Me.IngredientType = Null
Me.cbIngredient.SetFocus
Set rs = Nothing
End Sub
As mentioned, this thing has worked perfectly for 18 months until just a few days ago so my theory is that something has changed somewhere and my guess is it has to do with Access since SQL Server was not updated (But MS Access probably was).
The SQL Field Type for the error line is set to 'FLOAT' which corresponds with the values I am trying to enter.
Thanks for your help and suggestions.
UPDATE: Stepping through the Debugger it actually shows a 'Type Mismatch' error initially only so the 'No Current Record' additional error message is likely due to the first error and displays simultaneously. Still don't know why there's a type mismatch error though.
rs.Fields(5)andMe.Quantity? - GSerg