Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple vba statement not compiling

Status
Not open for further replies.

aperture

Programmer
Jul 25, 2001
22
US
hello all,

working within a class module, the action to be executed after evaluating an if statement is a simple GoTo as noted below. the compiler tells me that the label is not defined, and highlights the GoSub statement.

If varInterest_State = "NJ" Then:
GoSub checkLimit:
End If
End Sub

Public Sub checkLimit()

i have also tried using a GoTo and a simple label such as checkLimit: , but this produces the same error. i am writing this spaghetti style because there are many subs involved in the project that do not use the same variables or tables and are housed on different forms.

if anyone can help, i would appreciate it.

thanks,

ap
 
If varInterest_State = "NJ" Then:
call checkLimit
End If
End Sub

Public Sub checkLimit()

Use GoTo only when it's in the same function/sub, if at all. GoTO should only be used in error trapping. It makes your code hard to read.
 
Heck, you could simply do without the "call" and it would be fine too.

Gary
gwinn7
 
Databaseguy

good call. literally.

it worked well, thanks!

ap
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top