K
Kurt
I have a parameter query which shows all records
containing a null value for a particular ID (the
parameter). For example, the query shows that ID 00068
has three missing values (Rspns):
RspnsID QstnID Rspns
00068 4
00068 9
00068 12
When the user tries to leave a subform, I would like to
run this query and, if there are any records with null
values for the ID he's on, show a message telling the
user to complete the missing information, prevent the
record from being saved, and keep the form open on the
record (e.g., if he tried to close the form or move to
another record).
I assume the code would go in the Unload or BeforeUpdate
event of the subform, but I'm not sure of the syntax.
Here's what I have so far:
------------------------------------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
DoCmd.OpenQuery "qryNullResponses"
IF *query shows any records with null values for this
ID* THEN
MsgBox "You cannot save the data until you fill
in all of the questions. " & _
"Use the missing value (-9) if needed.",
vbCritical, "Missing Data"
DoCmd.RunCommand acCmdUndo
Else
'do nothing
End If
End Sub
-----------------------------------------------
What's the proper syntax to use to make use of the
results of the query? Thanks.
Kurt
containing a null value for a particular ID (the
parameter). For example, the query shows that ID 00068
has three missing values (Rspns):
RspnsID QstnID Rspns
00068 4
00068 9
00068 12
When the user tries to leave a subform, I would like to
run this query and, if there are any records with null
values for the ID he's on, show a message telling the
user to complete the missing information, prevent the
record from being saved, and keep the form open on the
record (e.g., if he tried to close the form or move to
another record).
I assume the code would go in the Unload or BeforeUpdate
event of the subform, but I'm not sure of the syntax.
Here's what I have so far:
------------------------------------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
DoCmd.OpenQuery "qryNullResponses"
IF *query shows any records with null values for this
ID* THEN
MsgBox "You cannot save the data until you fill
in all of the questions. " & _
"Use the missing value (-9) if needed.",
vbCritical, "Missing Data"
DoCmd.RunCommand acCmdUndo
Else
'do nothing
End If
End Sub
-----------------------------------------------
What's the proper syntax to use to make use of the
results of the query? Thanks.
Kurt