MS Access Form Events – PT1

In this video I talk about how to program vba object items like the ms access form.

Specifically we look at the Access Form Open Event, and add a password prompt in the open event of the form, cancelling the open event if it is incorrect.

Also we will look at controlling the Form_Load with a public variable and the Form_Current event.

The possibilities for the Form_Current event procedure.
-diplay a message box
-display data in the caption of the form.
-display the customer’s previous order
-display all the books by the publisher (based on publisher id)
-perform form level calculation on form data

Remember:
The Current Event happens before the Load Event.

Option Compare Database
Option Explicit

Public strUser As String


Private Sub Form_Current()

    'possibilities for the current record.
    'diplay a message box
    'display data in the caption of the form.
    'display the customer's previous order
    'display all the books by the publisher (based on publisher id)
    'perform form level calculation on form data
    

    'Caption
    
    If Len(Me.txtTitle) Then
        Forms!frmFormEvents.Caption = txtTitle.Value
    End If
    
    
    
End Sub

Private Sub Form_Load()

    MsgBox "Welcome, " & strUser
End Sub


Private Sub Form_Open(Cancel As Integer)
    
    'happens before the load event
    
    Dim strPassword As String
    
    strUser = InputBox("Enter The User")
    
    strPassword = InputBox("Enter The Password")
    
    If strPassword <> "Password" Then
        MsgBox "Incorrect Password"
        Cancel = True
    End If
    
End Sub

<< VBA Form Object Event Procedures | MS Access Form Events – PT2 >>

Offsite Related Information:

“Go Fund Me” Page


($5 suggested amount)

(…10% of your gift amount will go to charity)

Free! Subscribe To Our YouTube Channel!

Free MS Access VBA Programming Course

Facebooktwitterredditpinterestlinkedinmailby feather
Tags: , , , , , ,