473,441 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,441 developers and data experts.

VBA - Event Driven Programming

MMcCarthy
14,534 Expert Mod 8TB
VBA is described as an Event driven programming language. What is meant by this?

Access, like most Windows programs, is an event driven application. This means that nothing happens unless it is in response to some event that has been detected by the application.

The steps are fairly straightforward:
  • An event happens
  • The event is detected by the application
  • The application responds to the event
The Windows OS will automatically detect when an event has occured, like a mouse move, mouse click, form load, etc. If the OS doesn't find a VBA procedure relating to that event it will just go with its default behaviour for that event. The programmer does not need to determine when a particular event happens as Windows does that for you. If you program a procedure to respond to that particular event, then it will override the default behaviour for that event. Therefore, the programmer only needs to code those events where something other than the default behavior should occur. For example, the default behaviour if a button is clicked is that the button gains focus. You only need to code any other tasks you wish to be performed when this event occurs.

Although the obvious event for a button is the Click (On Click) event there are actually 12 possible events associated with a button.

To code an event:

Right click on the object or control you wish to program an event for. Go to properties and go to the Event tab. Choose the event you wish to code e.g. On Click for a button control. Click on the builder button (the one with three dots) and select Code Builder from the list. This will open the Visual Basic Editor with the opening and closing lines of the event procedure already coded. Everything you put between these two lines will execute when the button is clicked.

Every form and report object can have events programmed on them, as can all the controls in those same forms and reports.

Below are some of the more common events with details of when they occur:



There are many more events but these should get you started.
Attached Images
File Type: jpg VBA Events.jpg (73.3 KB, 2593 views)
Nov 26 '07 #1
0 11257

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: alanrn | last post by:
For all you seasoned VB programmers this is going to be a no brainer. However, as a C programmer learning VB I'm having trouble getting my arms around the event-driven nature of VB. Suppose I...
4
by: christopher diggins | last post by:
I just wrote an article on using template specializations for event-driven programming ( http://www.artima.com/weblogs/viewpost.jsp?thread=84958 ). Are there any other examples of this kind of...
1
by: Csaba Gabor | last post by:
Maybe someone has an idea about this... I have two PHP scripts and they would like to efficiently communicate (on a a callback or event driven basis) with each other. If these are CLI versions of...
3
by: msch-prv | last post by:
I am fairly new to PHP. I started creating a variety of classes (calendars, input forms, combo boxes, etc. ) but I am running into code overhead when I integrate these objects (testing for POST,...
14
by: Snor | last post by:
I'm attempting to create a lobby & game server for a multiplayer game, and have hit a problem early on with the server design. I am stuck between using a threaded server, and using an event driven...
4
by: AzizMandar | last post by:
C++ Event Coding Questions I have done some simple programs in C++ and read a lot of good C++ books (Including The C++ Programing Language, and C++ Primer) I am trying to understand and...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
8
by: Brad Walton | last post by:
Hello. First post, but been doing a bit of reading here. I am working on a project in Java, but decided to switch over to C# after seeing some of the additional features I can get from C#. One of...
15
by: Phillip B Oldham | last post by:
Are there any python event driven frameworks other than twisted?
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.