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!

Scope issue Variable not defined 1

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
US
Recently I have moved as much code as I can into functions. The issue I am having is when I am calling the procedure from a form, whatever variables I am using come up as variable not defined. I add Dim statements in the form to remove trhe error message. Is there another way to declare a variable instead of having to dim it?

Tom
 
>So you cannot just Call it

Well ... you can. Perfectly legitimate. Sometimes you might call a function without caring about the return value, in which case Call is legitimate (and it might be worth knowing that under the covers a VBA procedure is implemented in exactly the same as a function, but the return value is discarded and never passed on to the VBA program; in other words, a VBA Procedure is just a semantic nicety ... )

Having said that, most of the return values here are actually being returned in the parameters, so converting to a procedure and using a UDT might make some sense ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top