Prevent Insertion Of Blank Records

casper

Registered User.
Local time
Today, 00:55
Joined
Aug 26, 2006
Messages
12
I have a form that is opened by the following code:
Code:
Private Sub Status_AfterUpdate()
If Status.Value = "WIP - Snagged" Or Status.Value = "WIP - Suspended" Then
DoCmd.OpenForm "NotesJobChanged", , , acFormAdd
Forms!NotesJobChanged!txtJobNo.Value = Me!txtJobNo.Value
Forms!NotesJobChanged!Date.SetFocus
End If

This 'NotesJobChanged' form has three text boxes on it - JobNo, Date & Note. The JobNo is autofilled from the code above. If nothing is entered into the other fields and the form is closed this record is entered into the database with only the JobNo filled in.

What I want is a way to force the user to enter data into these fields. I don't want to set the 'Required' property of the field to yes as it generates an awful system error message. If the user attempts to close the form without filling it out can they be reminded that they have to, but with an option then to close the form if they really don't want to enter any data? If they do chose to close without filling it out can it be prevented from being added to the database.

Hope this makes sense :)

Many thanks in advance

Michael
 
you STILL should set the fields to required as a fail safe

BUT declare a form error event

(or use the form before update event)

both of which will intercept the access error, and enable you to test the error code, and provide a more graceful error message

try

msgbox("Error: " & err.number & & " Desc: " & err.description)
 
Last edited:

Users who are viewing this thread

Back
Top Bottom