0
votes

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.

1
Have you tried using the debugger and observe the types and values of rs.Fields(5) and Me.Quantity? - GSerg
Hi @GSerg I am not sure what you mean or how to 'observe' the values in the debugger. I just see the code that is throwing the error highlighted in the debugger and the error message that pops up, but I don't see the values being passed. - Robert Santen
@Gserg aah, I see, yes, I can see the value and type and they are show to be of the correct format type and value. - Robert Santen
"Type mismatch" with DAO and all of a sudden? Sounds very much like the recent Access bug with DECIMAL columns. stackoverflow.com/questions/62344861/data-type-number-decimal - Andre
Does this answer your question? Data type Number-Decimal - Andre

1 Answers

0
votes

@Andre has the answer! It was, of course, a bug that crept in with an MS Access update.