Get user to enter all information

  • Thread starter Thread starter b_lwalker
  • Start date Start date
B

b_lwalker

I've developed a project database that works quite well - but often
times users can be lax in entering all necessary data.

I've got a sub routine that fires for the Form's BeforeUpdate event
that can check the main form's controls - but I run into trouble with
the subforms. In order to stop the user leaving the record before the
information is entered, I Cancel the BeforeUpdate event...but the
record must update in order to set focus to a subform.

At the moment I'm using the following logic:

If ControlName = 0 then
MsgBox "Enter Data message"
ControlName.SetFocus
Cancel = True
Exit Sub
End If

I have the Exit Sub there as I test four different controls (two of
which are subforms) and don't want all the messages jumping up at the
same time. Does anyone have a better way of doing this?

Many thanks,

Bruce Walker
 
Typically your main form is bound to one table, and your subform is bound to
a related table.

If that's your situation, the record in the main table must be created
before you can create a matching record in the related table. Therefore you
cannot require that a subform record exists as a condition of creating the
record in the main table.

The subform has its own Form_BeforeUpdate event. Use that event to validate
the record in the related table.

(Hopefully you don't have a form and subform bound to the same table. That
will potentially give you several problems.)
 
Back
Top