Hi all,
Using access 2k
I have a form that is called "frm_Receipt", this form is set to data entry mode, and it's data source is a table called "tbl_RMADetails". Out of the 5 text boxes and two buttons on this form, two of the text fields ("serial" and "part") are required fields.
To control this, I have set the two fields to required in the table. The problem is I don't really like the error messages that are generated whenever the user tries to close the form and either of these fields are blank.
The close button used is the "X" at the top right of the screen:
MsgBox1 = The field [fieldname] cannot contain a null value because the required property for this field is set to true. Enter a value for this field
MsgBox2 = You cannot save the record at this time
Microsoft access may have encountered an error when trying to save the record. If you close the object now, the database changes you made will be lost. Do you wish to close anyway? YES/NO
I have a save button on the form that I have the following code attached to. I have included some error handling, and this appears to work okay.
Private Sub SaveRMA_Click()
On Error GoTo Err_SaveRMA_Click
SetKey
Caption = "Product for RMA: " & Me.RMAHold & " saved!!"
Me.TimerInterval = 1000
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.GoToRecord , , acNewRec
Me.RMA.SetFocus
Exit_SaveRMA_Click:
Exit Sub
Err_SaveRMA_Click:
Select Case Err.Number
Case "3314"
MsgBox "Please enter a valid Part and Serial number." & vbCrLf & "These fields cannot be empty", vbOKOnly + vbInformation, "Missing data required"
Me.Part.SetFocus
Case Else
MsgBox (Err.Number & vbCrLf & Err.Description)
End Select
Resume Exit_SaveRMA_Click
End Sub
The main reason why I can't code around someone closing the form prematurely like I did with the save button is that I don't know what, or even if error numbers are being generated. I've also tried If statements on the form_close sub and the messages that I want have displayed but this doesn't suppress the system messages which still appear.
Can anyone help?
Thanks in advance, tadynn
Using access 2k
I have a form that is called "frm_Receipt", this form is set to data entry mode, and it's data source is a table called "tbl_RMADetails". Out of the 5 text boxes and two buttons on this form, two of the text fields ("serial" and "part") are required fields.
To control this, I have set the two fields to required in the table. The problem is I don't really like the error messages that are generated whenever the user tries to close the form and either of these fields are blank.
The close button used is the "X" at the top right of the screen:
MsgBox1 = The field [fieldname] cannot contain a null value because the required property for this field is set to true. Enter a value for this field
MsgBox2 = You cannot save the record at this time
Microsoft access may have encountered an error when trying to save the record. If you close the object now, the database changes you made will be lost. Do you wish to close anyway? YES/NO
I have a save button on the form that I have the following code attached to. I have included some error handling, and this appears to work okay.
Private Sub SaveRMA_Click()
On Error GoTo Err_SaveRMA_Click
SetKey
Caption = "Product for RMA: " & Me.RMAHold & " saved!!"
Me.TimerInterval = 1000
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.GoToRecord , , acNewRec
Me.RMA.SetFocus
Exit_SaveRMA_Click:
Exit Sub
Err_SaveRMA_Click:
Select Case Err.Number
Case "3314"
MsgBox "Please enter a valid Part and Serial number." & vbCrLf & "These fields cannot be empty", vbOKOnly + vbInformation, "Missing data required"
Me.Part.SetFocus
Case Else
MsgBox (Err.Number & vbCrLf & Err.Description)
End Select
Resume Exit_SaveRMA_Click
End Sub
The main reason why I can't code around someone closing the form prematurely like I did with the save button is that I don't know what, or even if error numbers are being generated. I've also tried If statements on the form_close sub and the messages that I want have displayed but this doesn't suppress the system messages which still appear.
Can anyone help?
Thanks in advance, tadynn