K
Kurt
I have a main form with one subform, used to enter survey
responses. The subform has two visible controls, QstnText
and cboRspns, which are populated when the user enters a
survey date on the main form and clicks an "Enter Survey"
button. Then the user proceeds to enter a response for
each question populated (there's a total of 22
questions).
When the user is done, I would like to ensure that every
question has been answered (i.e., cboRspns Is Not Null
for every question). If this condition isn't satisfied,
the user would be prompted with a message when he tries
to add another record or leave the form. The record would
not be saved.
It seems I need to have code in the Before Update event
of *both* the main form and the subform. The code in the
main form would prevent data from being saved if the user
enters a survey date but doesn't enter any of the subform
data (e.g., if he didn't click on the "Enter Survey"
button which populates the subform) and instead just
closed the form. Second, the code in the subform would
check for any null values in cboRspns and prevent the
save if needed.
I just can't seem to figure out the code for this or if
this is even the best way to go. Any ideas? Thanks.
- Kurt (some details below)
The RecordSource of the main form:
-------------------------------------------
SELECT DISTINCTROW tblSrvRspns.RspnsID,
tblSrvRspns.SurveyDate
FROM tblSrvRspns
ORDER BY tblSrvRspns.RspnsID;
The RecordSource of the subform (abbreviated):
---------------------------------------------------------
SELECT DISTINCTROW tblResponses.*, tblQuestions.QstnText,
tblQuestions.QstnNum
FROM tblResponses
RIGHT JOIN tblQuestions ON
tblResponses.QstnID=tblQuestions.QstnID
ORDER BY tblQuestions.QstnNum;
The Row Source for cboRspns is:
responses. The subform has two visible controls, QstnText
and cboRspns, which are populated when the user enters a
survey date on the main form and clicks an "Enter Survey"
button. Then the user proceeds to enter a response for
each question populated (there's a total of 22
questions).
When the user is done, I would like to ensure that every
question has been answered (i.e., cboRspns Is Not Null
for every question). If this condition isn't satisfied,
the user would be prompted with a message when he tries
to add another record or leave the form. The record would
not be saved.
It seems I need to have code in the Before Update event
of *both* the main form and the subform. The code in the
main form would prevent data from being saved if the user
enters a survey date but doesn't enter any of the subform
data (e.g., if he didn't click on the "Enter Survey"
button which populates the subform) and instead just
closed the form. Second, the code in the subform would
check for any null values in cboRspns and prevent the
save if needed.
I just can't seem to figure out the code for this or if
this is even the best way to go. Any ideas? Thanks.
- Kurt (some details below)
The RecordSource of the main form:
-------------------------------------------
SELECT DISTINCTROW tblSrvRspns.RspnsID,
tblSrvRspns.SurveyDate
FROM tblSrvRspns
ORDER BY tblSrvRspns.RspnsID;
The RecordSource of the subform (abbreviated):
---------------------------------------------------------
SELECT DISTINCTROW tblResponses.*, tblQuestions.QstnText,
tblQuestions.QstnNum
FROM tblResponses
RIGHT JOIN tblQuestions ON
tblResponses.QstnID=tblQuestions.QstnID
ORDER BY tblQuestions.QstnNum;
The Row Source for cboRspns is: