Slight change to Script!

B

Bob

Any help with this would be appreciated.......Bob

Private Sub cmdClose_Click()
If IsNull(Me.subHorseDetailsChild.Form.OwnerID) Then
If Me.Dirty Then
Me.Undo
End If
'****** I want the form not to save if OwnerPercentage is 0%*******
If IsNull(Me.subHorseDetailsChild.Form.OwnerPercentage) Then
If Me.Dirty Then
Me.Undo
End If
If IsNull(Me.subHorseDetailsChild.Form.OwnerID) Or _
(IsNull(tbName) And IsNull(cbFatherName)) Then

If Me.Dirty Then
Me.Undo
End If

End If
End If
End If
DoCmd.Close acForm, Me.Name

End Sub
 
J

John W. Vinson

Any help with this would be appreciated.......Bob

Private Sub cmdClose_Click()
If IsNull(Me.subHorseDetailsChild.Form.OwnerID) Then
If Me.Dirty Then
Me.Undo
End If

okaaaayyyy...

This means "If any changes have been made to the data on the form, erase those
changes and restore the form to its previous value".
'****** I want the form not to save if OwnerPercentage is 0%*******
If IsNull(Me.subHorseDetailsChild.Form.OwnerPercentage) Then

This checks to see if the OwnerPercentage value has not been filled in. It
could have been filled in with 0 and this If would not execute.

To check for either null *or* zero use

If NZ(Me.subHorseDetailsChild.Form.OwnerPercentage) = 0. Then
If Me.Dirty Then
Me.Undo
End If

You've done this already...
If IsNull(Me.subHorseDetailsChild.Form.OwnerID) Or _
(IsNull(tbName) And IsNull(cbFatherName)) Then

If Me.Dirty Then
Me.Undo
End If

and you've done THIS already. What do you intend for it to accomplish?
End If
End If
End If
DoCmd.Close acForm, Me.Name

End Sub

I'd do ALL of this in the Form's BeforeUpdate event rather than its Close
event; and rethink the logic, because checking values on a Subform only checks
*the currently selected record* on the subform. There might be no record, or
many records on the subform.

John W. Vinson [MVP]
 

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

Top