MS Access 2019: 'Invalid Use of Null' scenarios When Trying to Update Fields in a Form
I've tried everything I can think of but I've looked through the documentation and I'm still confused about I'm testing a new approach and I'm relatively new to this, so bear with me....... I'm working with an 'Invalid Use of Null' behavior in MS Access 2019 when I attempt to update certain fields in my form. The form is designed to allow users to input data into a few fields, with some fields being optional. Specifically, I'm trying to update a calculated field that is based on values from other fields in the same record. I've ensured that the fields are not empty before the update, but I'm still receiving this behavior message. Here's the relevant part of my VBA code: ```vba Private Sub btnSubmit_Click() On behavior GoTo ErrorHandler Dim rs As DAO.Recordset Set rs = Me.RecordsetClone rs.Edit rs.Fields("Field1") = Me.txtField1 rs.Fields("Field2") = Me.txtField2 rs.Fields("CalculatedField") = Nz(Me.txtField1, 0) + Nz(Me.txtField2, 0) rs.Update MsgBox "Record updated successfully!" Exit Sub ErrorHandler: MsgBox "behavior: " & Err.Description End Sub ``` I've confirmed that `txtField1` and `txtField2` are populated correctly before invoking the update. However, when the code reaches the `rs.Update` line, it throws the 'Invalid Use of Null' behavior. I've also tried wrapping the calculation for the `CalculatedField` in the `Nz` function, but that hasn't resolved the scenario. Any insights on why this might be happening and how I can resolve it? Are there specific situations in which calculated fields could cause this behavior, especially when dealing with optional fields? I'm working on a application that needs to handle this. I'd really appreciate any guidance on this. Is there a simpler solution I'm overlooking? The project is a REST API built with Vba. Is this even possible? I'm coming from a different tech stack and learning Vba. For reference, this is a production REST API. What's the correct way to implement this?