Retaining a value

I use the code below to determine a value, however later in the procedure I would like to use it again and the value is empty?  Is there a way to make this a global value so it is not lost?  Or a way to carry the value from one procedure to another?  Trying to determine just where I am losing it.

session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").Text = strValidMatlNum
RWayneHAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Glenn RayExcel VBA DeveloperCommented:
You could declare strValidMatlNum as a Global variable (added outside your subroutine).  This will allow the value to be used in all modules:
Option Explicit
Global strValidMatlNum as String

Sub subroutine()
.
.
.
End Sub

Open in new window


Be sure you don't have other declarations for the same variable name elsewhere.  I will sometimes create a module exclusively for global variables.

-Glenn
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RWayneHAuthor Commented:
It worked!!  Thanks... but if some reason I could not use Ln1?  I made the procedure stop at places were I was setting a variable to Y or X...  different one..  After I commented that out it worked.  Any thoughts on the Ln 1
0
NorieAnalyst Assistant Commented:
RWayneH

You should always use Option Explicit as it helps you find undeclared variables, and you should always declare your variables.:)
0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Glenn RayExcel VBA DeveloperCommented:
^ What imnorie said.    If you add the Option Explicit and then do a compile (VBA menu: Debug - Compile VBA Project) you'll be alerted to any/all undeclared variables.

-Glenn
0
RWayneHAuthor Commented:
Thanks for the help.
0
Glenn RayExcel VBA DeveloperCommented:
You're welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.