UbiqutyDegins
asked on
Access 2010 Error Handling
I get an Error when trying to add error handing.
I am trying to to add Error handling to my code. I would like a MsgBox to pop up reminding the user to make sure all fields have been entered before adding the record to the table.
I keep getting "Invaild use of Null" as an error.
I am trying to to add Error handling to my code. I would like a MsgBox to pop up reminding the user to make sure all fields have been entered before adding the record to the table.
I keep getting "Invaild use of Null" as an error.
Private Sub cmdUpdatePart_Click()
On Error GoTo Err_UpdatePart_Click
Dim db As Database
Dim updatePart As String
Dim part As String
Dim man As String
Dim des As String
Dim ce As String
Dim wj As String
Dim ss As String
Dim he As String
Dim pack As String
Set db = CurrentDb
If ([Forms]![frmMain]![subfrmProdSpecs].[Form]![txtPartNum] = Null) Then
MsgBox "You must enter a Part Number", vbOKOnly
ElseIf ([Forms]![frmMain]![subfrmProdSpecs].[Form]![txtDescription] = Null) Then
MsgBox "Please enter a Description of the part.", vbOKOnly
End If
part = [Forms]![frmMain]![subfrmProdSpecs].[Form]![txtPartNum]
man = [Forms]![frmMain]![subfrmProdSpecs].[Form]![txtManufacturer]
des = [Forms]![frmMain]![subfrmProdSpecs].[Form]![txtDescription]
ce = "I:\Product Specifications\Cold End\" & [Forms]![frmMain]![subfrmProdSpecs].[Form]![txtCE_Packet]
wj = "I:\Product Specifications\Water Jet\" & [Forms]![frmMain]![subfrmProdSpecs].[Form]![txtWJ_Packet]
ss = "I:\Product Specifications\Silk Screen\" & [Forms]![frmMain]![subfrmProdSpecs].[Form]![txtSS_Packet]
he = "I:\Product Specifications\Hot End\" & [Forms]![frmMain]![subfrmProdSpecs].[Form]![txtHE_Packet]
pack = "I:\Product Specifications\Packaging\" & [Forms]![frmMain]![subfrmProdSpecs].[Form]![txtPack_Packet]
updatePart = "INSERT INTO tblParts VALUES ('" & part & "', '" & man & "', '" & des & "', '" & ce & "', '" & wj & "', '" & ss & "', '" & he & "', '" & pack & "')"
DoCmd.RunSQL (updatePart)
Err_UpdatePart_Click:
If ([Forms]![frmMain]![subfrmProdSpecs].[Form]![txtPartNum] = Null) Then
MsgBox "You must enter a Part Number", vbOKOnly
ElseIf ([Forms]![frmMain]![subfrmProdSpecs].[Form]![txtDescription] = Null) Then
MsgBox "Please enter a Description of the part.", vbOKOnly
Else: MsgBox Err.Description
End If
Resume Exit_UpdatePart_Click
Exit_UpdatePart_Click:
Exit Sub
End Sub
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.