G
Guest
I have a form in which I run a Before Update event that verifies whether
certain fields contain data. If they do not, the user needs to enter values
in those fields or the record will not be saved. My Before Update event is
along the lines of:
If IsNull(Me.txtStartDate) Then
Me.txtStartDate.SetFocus
Call Validate
Cancel = True
ElseIf IsNull (Me.txtDueDate) Then
Me.txtDueDate.SetFocus
Call Validate
etc. as before, through two more controls
End If
My form has four tab controls, each for a different part of the process (and
each typically filled out by a different person). The code I have shown is
for the first tab. After this code is a similar block of code (still in
Before Update) that checks to see if the second tab control is complete, then
the third tab control, then the fourth. Since the first tab control needs to
have all four text boxes filled in for the record to be saved, and since
clicking the second tab control caused the record to be saved (and triggers
the Before Update event), before the code checks the second tab control it
verifies that one of the text boxes on the first tab control is not null (if
one of the text boxes is null they all are), and so forth for the third and
fourth tab controls.
One person starts the form (which is used to make a recommendation). That
person needs to fill in the four text boxes on the first tab control, after
which they typically navigate away from the record. Later, somebody else
enters into text boxes on the second tab control the response to the
recommendation. Again, all fields (3) need to be filled in. Another person
follows up (third tab control) and a fourth issues final approval (fourth
tab). The code checks to see that the first tab control is complete before
checking the second, then that the second tab control is complete before
checking the third, etc. In this way the person starting the recommendation
does not confront the message box because of blanks in Response, Follow Up,
and Final Approval.
Validate is a public procedure that generates a message box advising the
user that they need to complete the record or it will not be saved. This
works as intended when saving the record from within the form (such as when
moving from one tab control to another). However, if the user enters
incomplete information and then closes the form, the Before Update code runs,
but the form closes whether or not the necessary fields have beeen completed.
What I would like to do is to stop the form from closing if the user needs
to go back and fill in missing information.
I have thought of some complicated things that might accomplish this, such
as testing the controls (on Dirty, maybe) as I have done in the Before Update
event. If information is incomplete the Close button would actually be a
Save button, but if the information is complete the faux Close button would
be invisible, and the real Close button would be hiding underneath.
I have gone into some detail about the database structure because in
addition to the specific question I would like a general opinion. As is
stands the database is pretty much a single form with about twenty-five
fields. Recommendation, Response, Follow-up, and Approval are all part of
the same record. I can't think of any reason why each of those sections
should have its own table, but would be interested in hearing thoughts on the
topic. If I am going to change the design, now is the time, before there are
real records.
certain fields contain data. If they do not, the user needs to enter values
in those fields or the record will not be saved. My Before Update event is
along the lines of:
If IsNull(Me.txtStartDate) Then
Me.txtStartDate.SetFocus
Call Validate
Cancel = True
ElseIf IsNull (Me.txtDueDate) Then
Me.txtDueDate.SetFocus
Call Validate
etc. as before, through two more controls
End If
My form has four tab controls, each for a different part of the process (and
each typically filled out by a different person). The code I have shown is
for the first tab. After this code is a similar block of code (still in
Before Update) that checks to see if the second tab control is complete, then
the third tab control, then the fourth. Since the first tab control needs to
have all four text boxes filled in for the record to be saved, and since
clicking the second tab control caused the record to be saved (and triggers
the Before Update event), before the code checks the second tab control it
verifies that one of the text boxes on the first tab control is not null (if
one of the text boxes is null they all are), and so forth for the third and
fourth tab controls.
One person starts the form (which is used to make a recommendation). That
person needs to fill in the four text boxes on the first tab control, after
which they typically navigate away from the record. Later, somebody else
enters into text boxes on the second tab control the response to the
recommendation. Again, all fields (3) need to be filled in. Another person
follows up (third tab control) and a fourth issues final approval (fourth
tab). The code checks to see that the first tab control is complete before
checking the second, then that the second tab control is complete before
checking the third, etc. In this way the person starting the recommendation
does not confront the message box because of blanks in Response, Follow Up,
and Final Approval.
Validate is a public procedure that generates a message box advising the
user that they need to complete the record or it will not be saved. This
works as intended when saving the record from within the form (such as when
moving from one tab control to another). However, if the user enters
incomplete information and then closes the form, the Before Update code runs,
but the form closes whether or not the necessary fields have beeen completed.
What I would like to do is to stop the form from closing if the user needs
to go back and fill in missing information.
I have thought of some complicated things that might accomplish this, such
as testing the controls (on Dirty, maybe) as I have done in the Before Update
event. If information is incomplete the Close button would actually be a
Save button, but if the information is complete the faux Close button would
be invisible, and the real Close button would be hiding underneath.
I have gone into some detail about the database structure because in
addition to the specific question I would like a general opinion. As is
stands the database is pretty much a single form with about twenty-five
fields. Recommendation, Response, Follow-up, and Approval are all part of
the same record. I can't think of any reason why each of those sections
should have its own table, but would be interested in hearing thoughts on the
topic. If I am going to change the design, now is the time, before there are
real records.