Zydeceltico
Registered User.
- Local time
- Today, 00:51
- Joined
- Dec 5, 2017
- Messages
- 843
Hi All! It's been awhile. ....and now I'm in need of your expertise again.
The Manufacturing Quality Inspection DB has been performing well (even though I'm thinking of replicating it and modifying the design ...but that's a different discussion).
But yesterday, out of nowhere I began receiving a "Run-time error '94', Invalid Use of Null" when saving/closing a Notes form (frmNotesAndIssues) and I haven't changed any code at all (until an hour ago).
What I have is a primary inspection form frmInspectionEvent whose Record Source is tblInspectionEvent. This table includes fields like Date, Inspection Type, Job Number, etc......and Notes (long text datatype).
The workflow is that I (or one of two other inspectors) will open frmInspectionEvent and enter Job Number, Inspected By, Operator Name...but we do not enter Notes at this time. That occurs after the actual inspection. Then we choose which type of inspection we are going to perform by clicking the appropriate button on frmInspectionEvent.
There are actually several different individual inspection forms for different processes (each one has its own table as a record source) but the behavior I'm going to describe persists across all of the inspection type forms. For this explanation, I'll use frmWelding.
So...we enter basic data on frmInspectionEvent, then click the button named "Welding" that opens frmInspectWelding (frmInspectionEvent remains open in the background. This form (frmInspectWelding) is where we actually collect inspection data - but the "Save" button on frmInspectWelding is not enabled until the user clicks one more button on frmInspectWelding. That button is labelled "Notes and Issues" and it opens frmNotesAndIssues with several unbound controls for collecting more general data (frmInspectWelding also remains open in the background).
Then the user clicks save on frmNotesAndIssues which triggers the following code; closes frmNotesAndIssues; and Enables the "Save" button on frmInspectWelding."
Here's the current code that is triggered. The SET Notes line seems to be the problem child. That line is written that way in order to be able to type fractions in the notes field (e.g., 3/4" and/or 5/16") and sentences with apostrophes (e.g., I don't know why this isn't working?).
That's the entire code for the "Save and Close" button on frmNotesandIssues. The original code had the bolded line above as this:
Using the original SET line, no error is thrown. Using longer SET Notes line above throws Runt-time error 94, Invalid Use of Null.
It is really important to also note that I have been using the more complex line above for months without issue. It is only in the past couple of weeks that I began receiving the error message and I don't know why. I haven't been in the back end modifying anything at all.
If I change the longer SET Notes line back to the simpler SET line, I don't receive the Null error message when typing fractions with commas. Instead, I receive an error message when I use an apostrophe in a sentence like: I'm not sure why this isn't working.
Thoughts?
Thanks,
Tim
The Manufacturing Quality Inspection DB has been performing well (even though I'm thinking of replicating it and modifying the design ...but that's a different discussion).
But yesterday, out of nowhere I began receiving a "Run-time error '94', Invalid Use of Null" when saving/closing a Notes form (frmNotesAndIssues) and I haven't changed any code at all (until an hour ago).
What I have is a primary inspection form frmInspectionEvent whose Record Source is tblInspectionEvent. This table includes fields like Date, Inspection Type, Job Number, etc......and Notes (long text datatype).
The workflow is that I (or one of two other inspectors) will open frmInspectionEvent and enter Job Number, Inspected By, Operator Name...but we do not enter Notes at this time. That occurs after the actual inspection. Then we choose which type of inspection we are going to perform by clicking the appropriate button on frmInspectionEvent.
There are actually several different individual inspection forms for different processes (each one has its own table as a record source) but the behavior I'm going to describe persists across all of the inspection type forms. For this explanation, I'll use frmWelding.
So...we enter basic data on frmInspectionEvent, then click the button named "Welding" that opens frmInspectWelding (frmInspectionEvent remains open in the background. This form (frmInspectWelding) is where we actually collect inspection data - but the "Save" button on frmInspectWelding is not enabled until the user clicks one more button on frmInspectWelding. That button is labelled "Notes and Issues" and it opens frmNotesAndIssues with several unbound controls for collecting more general data (frmInspectWelding also remains open in the background).
Then the user clicks save on frmNotesAndIssues which triggers the following code; closes frmNotesAndIssues; and Enables the "Save" button on frmInspectWelding."
Here's the current code that is triggered. The SET Notes line seems to be the problem child. That line is written that way in order to be able to type fractions in the notes field (e.g., 3/4" and/or 5/16") and sentences with apostrophes (e.g., I don't know why this isn't working?).
Code:
Private Sub cmdSaveClose_Click()
' This procedure checks to see if the data on the form has
' changed. If the data has changed, the procedure prompts the
' user to continue with the save operation or to cancel it. Then
' the action that triggered the BeforeUpdate event is completed.
' the SQL portion of this procedure updates various fields in tblInspectionEvent
' more in line with the actual shop floor workflow rather than
' included on frmInspectionEvent
Dim ctl As Control
Dim strSQL As String
strSQL = "UPDATE tblInspectionEvent " & _
" SET Notes = '" & Replace(Me.txtNotes, "'", "''") & "' , " & _
" Photos = '#" & Me.txtLinkToPhotos & "' , " & _
" OilCanning = '" & Me.cboCanningYesNo & "' , " & _
" CanningStopLine = '" & Me.cboCanningLineStop & "' , " & _
" CoatingIssues = '" & Me.cboCoatingIssueYesNo & "' , " & _
" CoatingStopLine = '" & Me.cboCoatingIssueLineStop & "' , " & _
" IssuesOther = '" & Me.cboOtherIssues.Column(1) & "' " & _
" WHERE InspectionEvent_PK = " & Me.txtInspectionEvent_ID & " ;"
Debug.Print strSQL
On Error GoTo Err_BeforeUpdate
' The Dirty property is True if the record has been changed.
If Me.Dirty Then
' Prompt to confirm the save operation.
If MsgBox("Do you want to save?", vbYesNo + vbQuestion, _
"Save Record") = vbNo Then
Me.Undo
DoCmd.Close
End If
Else
CurrentDb.Execute strSQL, dbFailOnError
DoCmd.Close
'MsgBox gFormName
Select Case gFormName
Case "frmInspectWelding"
Forms!frmInspectWelding!cmdSaveWeldAssemble.Enabled = True ' now that notes, issues, and photos s have been entered frmInspectWelding can be saved.
Case "frmInspectMill"
Forms!frmInspectMill.cmdSaveMillInspection.Enabled = True
Case "frmInspectAssemble"
Forms!frmInspectAssemble.CmdSaveAssemble.Enabled = True
Case "frmInspectFab"
Forms!frmInspectFab.cmdSaveFabInspection.Enabled = True
Case "frmInspectPaint"
Forms!frmInspectPaint.cmdSaveInspectPaint.Enabled = True
End Select
End If
Exit_BeforeUpdate:
Exit Sub
Err_BeforeUpdate:
MsgBox Err.Number & " " & Err.Description
Resume Exit_BeforeUpdate
End Sub
That's the entire code for the "Save and Close" button on frmNotesandIssues. The original code had the bolded line above as this:
Code:
" SET Notes = '" & Me.txtNotes & "' , " & _
Using the original SET line, no error is thrown. Using longer SET Notes line above throws Runt-time error 94, Invalid Use of Null.
It is really important to also note that I have been using the more complex line above for months without issue. It is only in the past couple of weeks that I began receiving the error message and I don't know why. I haven't been in the back end modifying anything at all.
If I change the longer SET Notes line back to the simpler SET line, I don't receive the Null error message when typing fractions with commas. Instead, I receive an error message when I use an apostrophe in a sentence like: I'm not sure why this isn't working.
Thoughts?
Thanks,
Tim