What is the purpose of the Me keyword in Access VBA?

What does the Me keyword mean?

“Me” refers to the Access form currently in focus.

Instead of writing out the entire form reference, you can just use the keyword “Me” which is easier.

Like:
Me.txtbox = “I am a textbox on the form that currently has the focus.”

or you can update a label’s caption on a form:

Here is the code:



Private Sub btnLoop_Click()
    Dim intCtr As Integer
    
    For intCtr = 1 To 100
        Me.lblText.Caption = "Loop count = " & intCtr
        
        'show the current count on the form   
        DoEvents

    Next
End Sub

And here is the video:




By the way, if you got or are getting value from the VBA information, please click the "Donate" button to give me a small token of your appreciation, thanks!


These posts may help answer your question too...

How To Make An Access Form Time Picker

Here is a relatively easy way to select times for your time entry text boxes. It’s a reusable form that allows you to pick a time from an Access form. There are probably different ways to do this but here is the way I would do it. On the form that has the time fields, […]

How to pick a file to load In VBA

How to Pick a File in VBA: FileDialog & GetOpenFilename Explained When building Excel VBA applications, you’ll often need to let users pick a file to load in VBA. Instead of hard-coding file paths, you can use built-in dialogs that make file selection easy and user-friendly. VBA offers two main approaches: FileDialog object (flexible, customizable) […]

How do I run VBA code when form opens

How do I run VBA code when form opens? There are probably several ways people do it, and some may say “He’s not doing it right. It’s done this way…” Good for you. This is the way I do it now, and it has worked well for me. 1. Find the form you want to […]

Simple Custom Progress Bar in Microsoft Access Forms Example

So I had a question come in regarding showing the progress of a task. Access has an ActiveX control that you can use called the ProgressBar and you can follow the guide in the image above to add it to your form. On you long running process you can show the progress bar so the […]


Support these sponsors:
Tags: , , ,
Previous Post

How to pick a file to load In VBA

Next Post

How do I handle errors in Access VBA code?

Leave a Reply

Your email address will not be published. Required fields are marked *