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

แชร์
ฝัง
  • เผยแพร่เมื่อ 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:
    TH-cam: / @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 9 หลายเดือนก่อน

    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  9 หลายเดือนก่อน +1

      Awesome. Glad you find them helpful.

  • @coderdecoder5947
    @coderdecoder5947 ปีที่แล้ว

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

    • @599CD
      @599CD  ปีที่แล้ว

      Thanks

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

  • @stuartround
    @stuartround ปีที่แล้ว

    Really useful and beautifully explained. Thank you!

    • @599CD
      @599CD  ปีที่แล้ว +1

      Glad you enjoyed it!

  • @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.

  • @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 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน

      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.