Error Checking

H

hootyeah

I am wanting to do the following to ensure that all relevant data is
collected:

1. Force users to input data into certain text boxes and combos

2. Where fields are left blank (due to some info not being known at
time of data entry) a null value is created so the record appears in a
query based on several tables. An example would be a record in the form
Timings where Activity and Date is known but the Time is not, and due
to the field being formatted for time I cant enter a value "unknown".
In this instance it is important that a save the record with Activity
and Date, and fill in Time value when this is known.

Should error checking be treated differently for text and combo boxes?
I have been partially successful in creating messages for blank text
boxes - but didnt work for combos. All I did was select Required at the
table and used the follwing code in the OnClick property of a save
button:

Private Sub CmdSave_Click()
Dim MyMsg As String
On Error GoTo saveerror
Me.Refresh

saveerror:
If Val(Err) = 3314 Then
MyMsg = "Please enter a value for these fields :-"
If Len(Me.Combo30 & "") = 0 Then MyMsg = MyMsg & Chr(13) &
"Client"
If Len(Me.Combo94 & "") = 0 Then MyMsg = MyMsg & Chr(13) &
"Job Status"

If Len(Me.[Job Name] & "") = 0 Then MyMsg = MyMsg & Chr(13)
& "Job Name"
If Len(Me.Combo96 & "") = 0 Then MyMsg = MyMsg & Chr(13) &
"Job Type"

MyMsg = MyMsg & Chr(13) & Chr(13) & "Or Press 'ESC' to undo."
MsgBox MyMsg, , "Values Required"
End If

Cheers in advance
 
L

Lee Robinson

You seem to have two contradictory statements here. In statement "1" you
say that you want to force used to put date into certain text boxes and
combos but in statement "2" you mention fields that are left blank because
some information is not available. It seems to me that you can't have it
both ways.

Access puts the default values into records when they are created and then
updates the fields with the value users enter in the text boxes and combo
boxes. If no default value is specified for a text field and the user does
not enter any value in the text box or combo box bound to that field then
Access will leave the value as Null. This is what you said you wanted.

So, I am at a loss to figure out what you want that Access is not doing for
you already.

Lee Robinson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top