Variable Scope & Visibility in Microsoft Access VBA (Public, Private, Dim, Global, etc.)

preview_player
Показать описание
In this Microsoft Access tutorial, I will teach you about variable scope and visibility in VBA. We'll learn about public vs. private, the keywords dim and global, and the different scopes including procedure-level, form-level, and database-level.

Sandra from Norfork, Arkansas (a Gold Member) asks: Can I use Dim X as String on multiple buttons on one form, or does each button require a separate character?  I've watched lots of videos, but have not found one yet that answers this question.

LEARN MORE:

PRE-REQUISITES:

RECOMMENDED COURSES:

LINKS:

BECOME A MEMBER:

ADDITIONAL RESOURCES:

KEYWORDS
access 2016, access 2019, access 2021, access 365, microsoft access, ms access, ms access tutorial, #msaccess, #microsoftaccess, #help, #howto, #tutorial, #learn, #lesson, #training, #database, #fasttips, Understanding variable scope and visibility, vba, invalid outside procedure, variable not defined, can't find the field referred to in your expression, run-time error '2465', application-defined or object-defined error, dim, private, public, global, compile invalid attribute in sub or function, procedure-level, form-level, database-level

QUESTIONS:
Please feel free to post your questions or comments below. Thanks.
Рекомендации по теме
Комментарии
Автор

I mean this is UNBELIEVABLE. I have been trying for days to find a way to do something re using field values between forms and this has nailed it! I'm creating a gallery form for my wife's cake business and couldn't figure how to grab text field contents to copy to another form's field to load the image from.

This is AWESOME. I should bin Google off and just trawl your videos.

Brilliant. BRILLIANT.

I've commented before to say my entry level database would have been BORING but your videos have turned it in to (what i think) is a work of art!!!

petewarby
Автор

Excellent. I’m truly impressed with your teaching ability and the way you organize things.

coderdecoder
Автор

Man Access is old school.. really wish you start making Oracle 19c courses, you teach really well and i have no one to guide me even tho it's alot better than access especially at large scale databases.

MadGenious
Автор

Excellent video, and an important topic too since the concept of scope and visibility applies to any programming language. Sometimes you also need to use naming convention to denote scopes. I use "G_" to prefix all global-level variables and "M_" to denote module-level ones.

rabidfollower
Автор

You have explained scope of variable in great detail and with working codes. That was great help, thx a ton.

ashishtrivedi
Автор

Really useful and beautifully explained. Thank you!

stuartround
Автор

Yes. Video quite helpful and comprehensive. A tutorial on building a SUM Module or function would be useful. In excel it is easy but for Access, it is not that easy.

satyabanukil
Автор

This is a great lesson on this topic Richard.
I haven't been able to specify a Public Variable in a query (a separate form) as defined (by name)..
Do you need to use a function to do that?
]

glennpitts
Автор

1:47 isn' there module level too?

artistryartistry
Автор

FRRRR all the layering n buttons i cant keep up

jazbaacademyarts