VBA procedure is a series of instruction written in VBA code that tell an application (like Access) exactly to perform a specific task. In VBA code, each step in the procedure is a single line of code (called statement). For instance, In Microsoft Access when the Access executes a procedure, it does so step-by-step, from the top down. Access does whatever the first statement tells it to do. Then it does the second statement tells it to do, and so forth, until it get to the end of the procedure.
Exactly when Access executes procedure is entirely up to you. You can tie the procedure to some event that happens on-screen. For example, you might want a procedure to perform its task as soon as some – one click a button. Or perhaps, you want your procedure to do its task whenever someone types an email address into a form. For now, just realize that you can tie any procedure that you have created to any event you like.
When the event to which you have tied your procedure occurs, Access calls the procedure. What that means is that Access does exactly what the VBA code tells it to do.
What is a procedure?
1. An event, such as clicking a button is called a procedure.
2. Access executes the first line in the called procedure then is executes the second line in the procedure; and so on
3. When Access encounters the end of procedure (End of Sub or End Function), it just stop executing the code and return to the normal state.
Some Sample of procedure
Example 1: Sum of Two Integer Value
Function SumTwoValue(a as integer, b as integer)
SumTwoValue=a+b
End Function
Example 2: Print the Value 0 to 10
Sub PrintValue()
Dim i as integer
For i=0 to 10 step 1
Debug.print i
Next i
End Sub
That is all for all VBA procedure. We are welcome to any comments.
0 comments :
Post a Comment