Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: sub or function not defined

Geek News

sub or function not defined
Walter 11/29/2008 2:49:00 PM
What is wrong in the following code to give this error? The
"Exit_ValidateOdometer" line is highlighted blue.

Private Sub ValidateOdometer(Cancel As Integer)
On Error GoTo Err_ValidateOdometer

'verify that odometer entry is not less than last
Dim varPrevOdometer As Variant

Set varPrevOdometer = Me.Parent!PrevOdometer

If Me.Odometer < varPrevOdometer Then
Cancel = True
Me.Odometer.SelStart = 0
Me.Odometer.SelLength = Len(Me.Odometer.Value)
MsgBox _
"The last odometer entered for this truck was " & _
varPrevOdometer & vbCrLf & _
"Please enter an odometer greater than or equal " & _
"to this.", , _
"Invalid Odometer Entry"
End If

Exit_ValidateOdometer
Exit Sub

Err_ValidateOdometer:
MsgBox Err.Number & Err.Description
Resume Exit_ValidateOdometer

End Sub
--
Thanks for your help!
Walter
Re: sub or function not defined
Rick Brandt <rickbrandt2[ at ]hotmail.com> 11/29/2008 2:59:05 PM
On Sat, 29 Nov 2008 06:49:00 -0800, Walter wrote:

[Quoted Text]
> What is wrong in the following code to give this error? The
....
> Exit_ValidateOdometer
> Exit Sub
>
> Err_ValidateOdometer:
> MsgBox Err.Number & Err.Description
> Resume Exit_ValidateOdometer
>
> End Sub

As a line label "Exit_ValidateOdometer" needs to have a colon (:) after
it.



--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Re: sub or function not defined
Walter 11/29/2008 3:30:01 PM
I figured it was something simple but I couldn't see it.
--
Thanks for your help!
Walter


"Rick Brandt" wrote:

[Quoted Text]
> On Sat, 29 Nov 2008 06:49:00 -0800, Walter wrote:
>
> > What is wrong in the following code to give this error? The
> ....
> > Exit_ValidateOdometer
> > Exit Sub
> >
> > Err_ValidateOdometer:
> > MsgBox Err.Number & Err.Description
> > Resume Exit_ValidateOdometer
> >
> > End Sub
>
> As a line label "Exit_ValidateOdometer" needs to have a colon (:) after
> it.
>
>
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt at Hunter dot com
>
Re: sub or function not defined
Walter 11/29/2008 3:38:01 PM
Now when I try to call "ValidateOdometer" I get an "Argument not optional"
error.

Private Sub Odometer_BeforeUpdate(Cancel As Integer)

Call ValidateOdometer

End Sub
--
Thanks for your help!
Walter


"Rick Brandt" wrote:

[Quoted Text]
> On Sat, 29 Nov 2008 06:49:00 -0800, Walter wrote:
>
> > What is wrong in the following code to give this error? The
> ....
> > Exit_ValidateOdometer
> > Exit Sub
> >
> > Err_ValidateOdometer:
> > MsgBox Err.Number & Err.Description
> > Resume Exit_ValidateOdometer
> >
> > End Sub
>
> As a line label "Exit_ValidateOdometer" needs to have a colon (:) after
> it.
>
>
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt at Hunter dot com
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net