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

Поделиться
HTML-код
  • Опубликовано: 15 сен 2022
  • 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:
    599cd.com/Scope
    PRE-REQUISITES:
    Intro to VBA: 599cd.com/IntroVBA
    Variables: 599cd.com/Variables
    For Next Loops: 599cd.com/ForNext
    RECOMMENDED COURSES:
    Access Developer 4: 599cd.com/ACD4
    Access Developer 31: 599cd.com/ACD31
    LINKS:
    Value From a Form: 599cd.com/FormName
    Microsoft Scope & Visibility: docs.microsoft.com/en-us/offi...
    BECOME A MEMBER:
    RUclips: / @599cd
    or My Site: 599cd.com/THMember
    ADDITIONAL RESOURCES:
    FREE Access Beginner Level 1: 599cd.com/Free1
    $1 Access Level 2: 599cd.com/1Dollar
    Donate to my Tip Jar: 599cd.com/TipJar
    Get on my Mailing List: 599cd.com/YTML
    Contact Me: 599cd.com/Contact
    TechHelp: 599cd.com/TechHelp
    Consulting Help: 599cd.com/DevNet
    Twitter: / learningaccess
    en.wikipedia.org/wiki/Microso...
    products.office.com/en-us/access
    microsoft.com/en-us/microsoft...
    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.

Комментарии • 21

  • @petewarby7158
    @petewarby7158 10 месяцев назад

    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!!!

    • @599CD
      @599CD  10 месяцев назад +1

      Awesome. Glad you find them helpful.

  • @coderdecoder5947
    @coderdecoder5947 Год назад

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

  • @ashishtrivedi8253
    @ashishtrivedi8253 Год назад

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

    • @599CD
      @599CD  Год назад

      You are welcome!

  • @rabidfollower
    @rabidfollower Год назад +1

    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.

    • @599CD
      @599CD  Год назад

      Thank you.

  • @stuartround
    @stuartround Год назад

    Really useful and beautifully explained. Thank you!

    • @599CD
      @599CD  Год назад +1

      Glad you enjoyed it!

  • @venkatyalamati3285
    @venkatyalamati3285 Год назад

    Thanks for the tutorial sir!!!

    • @599CD
      @599CD  Год назад

      My pleasure!

  • @MadGenious
    @MadGenious Год назад

    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.

    • @599CD
      @599CD  Год назад

      Access is where it's at.

  • @glennpitts1312
    @glennpitts1312 11 месяцев назад

    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?
    ]

    • @599CD
      @599CD  11 месяцев назад

      599cd.com/QQ

  • @artistryartistry7239
    @artistryartistry7239 Год назад

    1:47 isn' there module level too?

    • @599CD
      @599CD  Год назад

      Well, there are FORM modules and DATABASE modules (global modules) so that's why I didn't just say "module-level." Who's module is it?

    • @artistryartistry7239
      @artistryartistry7239 Год назад

      @@599CD Gotcha. It's amazing the number of terms surrounding modules their rules and their variables!

  • @GCCONLINECLASSES
    @GCCONLINECLASSES Год назад

    FRRRR all the layering n buttons i cant keep up

    • @599CD
      @599CD  Год назад

      Layering? Not me.