<%dim crumb crumb="Before Insert Event" crumb1="Before Insert" %> BeforeInsert Event
Home   Fees/Services   Access Templates   Tutorials  Tutorial Downloads   Articles   Search   Contact  Privacy  Links
<% response.write crumb2 %>
<% response.write crumb1 %>
 Home > Microsoft Access Tutorial > Form Event Tutorials <% response.write "> " & crumb %>

Access Event Tutorials:
Before Insert Event
After Insert Event
After Update Event
Before Update Event
Change Event
Close Event
Current Event
Double Click Event
Error Event
Exit Event
VBA Timer Event
Undo Event

Table-Level Events

Before Insert Event Access

Form Event - Visual Basic Code Example

The Form BeforeInsert event happens when the user types the very first character in a form new record, but before the record is actually created in the database table.

BeforeInsert Event Example:

Here we are manually coordinated two continuous forms together.  Access will not allow you to do this with dual continuous forms using link master and link child properties.  The code below takes the primary key (Trip_Guide_Daily_ID) in the master record and propagates it to the new record in the detail record using the before insert event.

Private Sub Form_BeforeInsert(Cancel As Integer)
    Me.Trip_Guide_Daily_ID = Me.Parent.Trip_Guide_Daily_ID
End Sub

Generally, the before insert event is great for loading values into fields that are not input by the user.  For instance a field called User_ID might be added to this record to automagically track who entered the record.  See user login example to view how to save special data fields during login for future use.

Form Triggers
Table Triggers
Form Flags
Table Triggers
Record Flags
Record Events

Microsoft Office:
MS Access 2003
Access 2007
Access 2010
Access 2013
Access 2016

Contact Information

<% Response.write "Copyright 2000-" & year(now) & " Blue Claw Database Design" %>