> Put your validation code in a boolean function:
>
> Public Function fnValidateEntry() as Boolean
>
> fnValidateEntry = FALSE 'this is just to be certain it's always false to
> start
>
> 'put your validation code here, except
> 'replace "DoCmd.CancelEvent 'stop the update"
> 'with fnValidateEntry = FALSE
>
> 'then at the end, after all your validation passes you put:
>
> fnValidateEntry = TRUE
>
> End Function
>
> Once that is done:
>
> Private Sub Command50_Click()
>
> If fnValidateEntry = FALSE then
> Exit Sub
> Else
> DoCmd.GoToRecord , , acNewRec
> Endif
>
> End Sub
>
>
>
>
>
> Lisa wrote:
> >Jill,
> >
> >Thank you.. i am still having a bit of trouble.. here is my code that i used
> >on the before update.. when i click on the button (see code further down for
> >this button) that i have on the form to add a new record it gives me the
> >first popup box where i am missing information then when I hit ok on that
> >popup box i get a microsoft visual basic popup box with a runtime error..you
> >cant go to the specified record.
> >
> >Can you figure out what I did wrong?
> >
> >Dim stMsgText As String
> >If Nz([Rnwl_MB_MidTerm], 0) = 0 Then ' if the field is null tell them
> > stMsgText = "Choose the policy type from the dropdown." ' text for the
> >error message
> > MsgBox stMsgText, vbOKOnly, "Missing Policy Type" 'put up a message box
> >explaining the error
> > DoCmd.CancelEvent 'stop the update
> >
> >ElseIf Nz([Segment], 0) = 0 Then ' if the field is null tell them
> > stMsgText = "Choose the segment from the dropdown." ' text for the
> >error message
> > MsgBox stMsgText, vbOKOnly, "Missing Segment" 'put up a message box
> >explaining the error
> > DoCmd.CancelEvent 'stop the update
> >
> >ElseIf Nz([RatingState], 0) = 0 Then ' if the field is null tell them
> > stMsgText = "Choose the rating state from the dropdown." ' text for the
> >error message
> > MsgBox stMsgText, vbOKOnly, "Missing Rating State" 'put up a message
> >box explaining the error
> > DoCmd.CancelEvent 'stop the update
> >
> >ElseIf Nz([PolNo1], 0) = 0 Then ' if the field is null tell them
> > stMsgText = "Input the policy number for policy number 1." ' text for
> >the error message
> > MsgBox stMsgText, vbOKOnly, "Missing Policy Number 1" 'put up a message
> >box explaining the error
> > DoCmd.CancelEvent 'stop the update
> >
> >ElseIf Nz([PolNo1-EffDate], 0) = 0 Then ' if the field is null tell them
> > stMsgText = "Input the policy effective date for policy number 1." '
> >text for the error message
> > MsgBox stMsgText, vbOKOnly, "Missing Policy Number 1 Effective Date"
> >'put up a message box explaining the error
> > DoCmd.CancelEvent 'stop the update
> >
> >ElseIf Nz([PolNo2], 0) = 0 Then ' if the field is null tell them
> > stMsgText = "Input the policy number for policy number 2." ' text for
> >the error message
> > MsgBox stMsgText, vbOKOnly, "Missing Policy Number 2" 'put up a message
> >box explaining the error
> > DoCmd.CancelEvent 'stop the update
> >
> >ElseIf Nz([PolNo2-EffDate], 0) = 0 Then ' if the field is null tell them
> > stMsgText = "Input the policy effective date for policy number 1." '
> >text for the error message
> > MsgBox stMsgText, vbOKOnly, "Missing Policy Number 2 Effective Date"
> >'put up a message box explaining the error
> > DoCmd.CancelEvent 'stop the update
> >
> >ElseIf Nz([PolicyTerm], 0) = 0 Then ' if the field is null tell them
> > stMsgText = "Choose the policy term from the dropdown." ' text for the
> >error message
> > MsgBox stMsgText, vbOKOnly, "Missing Policy Term" 'put up a message box
> >explaining the error
> > DoCmd.CancelEvent 'stop the update
> >End If
> >
> >> You can do your validation using code in the Before Update event of your
> >> form. Open the form's property box, go to the Event tab and click on the
> >[quoted text clipped - 7 lines]
> >> DoCmd.CancelEvent 'stop the update
> >> End If
> >
> >Code for Button to go to next record
> >Private Sub Command50_Click()
> >
> > DoCmd.GoToRecord , , acNewRec
> >
> >
> >End Sub
> >
> >> Jill
> >>
> >[quoted text clipped - 10 lines]
> >> >
> >> > Thanks for any information you can provide.
>
> --
> Message posted via AccessMonster.com
>
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200812/1>
>