Any code in the parent form is only going to work with the current row in
any subform (unless you put in looping code into the parent form). It
looks
as though you're using queries to do the copies. Why not create a query
that
checks where there are any "bad" rows in the originating data?
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
I have the following code in a button on the parent form.
If Len(Forms!POC_IP_A![OENTRY2_SUBA]![Descrip1] & vbNullString) = 0
Then
MsgBox "No Nulls Allowed"
ElseIf MsgBox("This will mark this order as 'Complete'. Additional
Items
can
not be added at this time. Do you wish to perfrom this action?",
vbYesNo,
"Warning") = vbNo Then
Cancel = True
ElseIf vbYes Then
DoCmd.SetWarnings False
x = XQuery("QryU:COMP_ORDER_POC_IP")
x = XQuery("QryD:TO_CO_POC_IP")
DoCmd.SetWarnings True
DoCmd.Close acForm, "POC_IP_A", acSaveNo
Forms!IP_SEARCH.Requery
End If
If I click on the control that is null when displayed, the code works.
This
is a continous form, so the control I am checking for NULL may not have
the
focus.
Thanks
:
Where did yout put that code? It looks as though you're trying to do
it
on
the parent form, not the subform. It needs to go in the form being
used
as a
subform.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
message
Hi Arvin,
Thanks for the response, though unfortunately, the code isn't
recognizing
a
Null value. I am checking for Null in a subform that is a continous
form.
I
changed the code as follows:
If Len(Me.OENTRY2_SUBA![Descrip 1] & vbNullString) = 0 Then
MsgBox "No Nulls Allowed"
Me.OENTRY2_SUBA![Descrip 1].SetFocus
End If
I purposely left a record in the 'Descrip 1' field in the table that
is
the
source for the subform. Any other suggestions? Thanks.
:
On a button click event, or even the form's BeforeUpdate event use
the
expression:
If Len(Me.ControlName & vbNullString) = 0 Then
MsgBox "No Nulls Allowed"
Me.ControlName.SetFocus
End If
add a similar expression for each control that you want to check.
If
you
use
the Before Update event, you'll also need to cancel it or it will
just
go
on
after the message box.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
message
Hello,
I have a form with a subform that is in continous view that
allows
the
user
to add/change records in a table. Before moving the records from
one
table
to
another, I want to check for Null in specific fields that are
tied
to 3
fields displayed on the Main form. No luck so far! Thanks in
advance!