Subform Input Validation

L

Lisa

I have a form that points to one table (PolicyInfo) with a sub form that
points to a table (policyRnwl) that has a one to one relationship with
policyinfo table. The policy info table has a check box for when they begin
processing the renewal. When opening the form it automatically checks off
the processing checkbox and saves the record. What I need to happen when
they hit new record is when that checkbox is checked I need all the fields on
the subform validated for input. I have the code on the subform already but
if the inputter doesn't every input anything on the subform and bypasses
input completely it bypasses the code for validation.

Is there a way to add the code on my main form to validate the input on the
subform. Here is the code i have on the subform.

Dim stMsgText As String
If Nz([SvcOps_RepCode], 0) = 0 Then ' if the field is null tell them
stMsgText = "Choose your rep code from the dropdown." ' text for the
Error message
MsgBox stMsgText, vbOKOnly, "Missing Rep Code" 'put up a message box
explaining the error
Cancel = True

ElseIf Nz([SvcOps_dateWorked], 0) = 0 Then ' if the field is null tell them
stMsgText = "Input today's date." ' text for the Error message
MsgBox stMsgText, vbOKOnly, "Missing Process Date" 'put up a message
box explaining the error
Cancel = True

ElseIf Nz([SplitPremium], 0) = 0 And Nz([Disposition], 0) = "Quoting" Then '
if the field is null tell them
stMsgText = "Input the split premium (if you don't have one input
0.00)." ' text for the error message
MsgBox stMsgText, vbOKOnly, "Missing No Action Disposition" 'put up a
message box explaining the error
Cancel = True

ElseIf Nz([Disposition], 0) = 0 Then ' if the field is null tell them
stMsgText = "Choose the disposition from the dropdown." ' text for the
Error message
MsgBox stMsgText, vbOKOnly, "Missing Disposition" 'put up a message box
explaining the error
Cancel = True

Any help would be greatly appreciated.
 
J

Jeanette Cunningham

Hi Lisa,
the only way I can imagine is to use some code together with a DCount to see
if there is a record for that particular ID in the policyRnwl table.
If no matching record, then cancel closing the subform or something similar.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top