How to Use Global Variables in Microsoft Access VBA

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024
  • In this episode, we're going to take a look at how to use a global variable in Microsoft Access so that we can populate a variable in our program and have it available for consumption by our forms, reports, macros, and other code in our project. Global variables are quite handy when you need to store different things in memory as your program runs, whether it is a string, array, object, or other things.
    Related Videos:
    How to Use Left, Right, Mid, Instr, and Trim on Strings in MS Access and VBA
    • How to Use Left, Right...
    How to Use DateAdd, DateDiff, and DatePart to Calculate Dates in MS Access
    • How to Use DateAdd, Da...
    How to Handle Line Breaks in Microsoft Access
    • How to Handle Line Bre...
    How to Open a RecordSet in Access VBA and Loop Through the Records
    • How to Open a RecordSe...
    How to Use BOF and EOF on Recordsets in MS Access
    • How to Use BOF and EOF...
    How to use With.. End With in MS Access VBA
    • How to use With.. End ...
    How to Use Global Variables in Microsoft Access VBA
    You are watching this video now!
    How to Use For Next Loops in MS Access VBA
    • How to Use For Next Lo...
    How to Use a Do While Loop in MS Access VBA
    • How to Use a Do While ...
    Interested in transforming your career or finding your next gig?
    system.billzon...
    Want my team to do a project for you? Let's get to it!
    system.billzon...
    Want to get access to premium content made just for you and have a chat with me? Find me on Patreon :
    / mackenziedataengineering
    Demo of my BZ RDP Cloaker:
    www.patreon.co...
    Want to work with me 1:1? Contact me today and book your free 20 min consultation!
    Contact form you can find at www.mackenziema...
    Follow me on social media:
    / mackenziedataanalytics
    / seamacke
    / seamacke
    / seamacke
    / psmackenzie
    Get Microsoft Office including Access:
    click.linksyne...
    Got a TH-cam Channel? I use TubeBuddy, it is awesome. Give it a try:
    www.tubebuddy....
    #msaccess #vba #dataengineering

ความคิดเห็น • 20

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

    Very well explained, i already know this stuff, i also use the TempVars collection in MS-Access, if a global value/variable is needed.

  • @hikmatmarashdeh2293
    @hikmatmarashdeh2293 2 ปีที่แล้ว +1

    thanks a lot for your explanation and demo, it helped me a lot.

  • @interestingamerican3100
    @interestingamerican3100 2 ปีที่แล้ว +1

    Commenting for the algorithm. Love the content!

  • @abdoulayetoure9965
    @abdoulayetoure9965 7 หลายเดือนก่อน +1

    Thank a lot for this vidéo it help me a lot

  • @RamachandranS20
    @RamachandranS20 2 ปีที่แล้ว +1

    Thank you - helped me!

  • @stanTrX
    @stanTrX 11 หลายเดือนก่อน +1

    Thanks Sean. How can i call a module anywhere in the forms? Is there a way to call it using a shortcut (just like we can do in excel )

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  11 หลายเดือนก่อน +1

      Great question and a key aspect of using Module objects vs Form code. The Global variables, Subs, and Functions in a Module can be used all throughout your program in Forms, Queries, and Reports simply by calling them by name. For example, if you had MyCodeToRun as a Sub in your module, you can run it by just using Form code: Form > Button > right-click Properties > Events > On Click > Elipsis ... > Code Builder > Editor opens with a new subroutine, Sub ... End Sub. You can simply type in MyCodeToRun between those lines and your module Sub will run. If you have ten other forms with similar functionality, you can do the same, meaning you can use one function 10 times instead of copying and pasting tons of code. So, short answer is: Form code, Report code, and Query expressions.

    • @stanTrX
      @stanTrX 11 หลายเดือนก่อน

      thanks ☺@@seanmackenziedataengineering

  • @gerfer6261
    @gerfer6261 2 ปีที่แล้ว +1

    Thanks 😊
    ? = is there a connector you know about in Power Automate use between Access and Excel please?

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  2 ปีที่แล้ว +1

      I believe you can use the Open SQL (for Access) and Excel connectors for that purpose.

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

    Sir, I have a calculative field. I want to create two variables a and b. I want to add both the variables to that calculating field. For example a is 5 and b is 2 and my result shall appear as (a + b) = 7. If it is possible, kindly make a tutorial on it. Regards

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

      I don't think I ever made a program to show math results! Great idea for a video 👍

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

      @@seanmackenziedataengineering Sir all of your replies I received so far are not only of great help for learners like us but also prompt and very easy to follow. Looking forward for your tutorial as you mentioned here Sir. Regards.

  • @artistryartistry7239
    @artistryartistry7239 2 ปีที่แล้ว +1

    You know your stuff, but you're not a good teacher. I'm not trying to be mean, I'm just giving honest feedback. There has to be real thinking and effort to make something clear and easy to understand, to put yourself in the mind of a person who may have no previous understanding of what you're doing. You have not applied that level of sophistication and polish to this work. As Steve Jobs said: "Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple." You haven't done that here.

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  2 ปีที่แล้ว +2

      All feedback is welcome. My teaching methods are not for everyone.
      Imagine that you're an analyst approaching a senior analyst's desk and asking about a topic. He pulls together some examples for you that he knows are good, then explains them to you. He shows the main concept only, without an encyclopedic explanation of every feature on that topic. Why? Because he knows that you're a smart analyst and, after understanding the main breakthrough will proceed to research additional ways that a technology can be used. If you have questions, you'll ask.
      That's what you'll find on my channel. Polished, no. Effective, yes.