Microsoft Office Tutorials and References
In Depth Information
Triggering a New Form Based on a Subform Selection
This code is behind the main form:
Option Compare Database¶
Option Explicit¶
' * * * * *
Private Sub btnCancel_Click()¶
' Close form¶
DoCmd.Close¶
End Sub¶
' * * * * *
Private Sub Form_Activate()¶
' Maximize form when it becomes active¶
DoCmd.Maximize¶
End Sub¶
Open the VBE (Alt+F11). The preceding code can be displayed by choosing the
btnCancel option in the left drop-down at the top of the code window. Selecting
Form shows the other subroutine.
The Docmd.Close command closes the form and returns to the previously
opened form. This way you get forms opening on top of one another in an
“Internet Browser” kind of way. This is a nice, simple way for users to navigate
a database, because most users are familiar with this functionality.
Finally the Docmd.Maximize in the Form_Activate event makes sure that the
form always fills the whole Access screen when opened or when control returns,
even after a user has resized the window.
Acs
Triggering a New Form Based on a Subform Selection
This procedure jumps to a record details form from a subform.
Example file:
A007.mdb with
forms
frmNameSelect,
frmNameUpdate
Scenario: On a datasheet subform with all available
information, offer the user the possibility to update the data
from a selected row on a separate form. Suppose you have a
list of open invoices that contain company name and amount
due. You can trigger the company information form to be
created when you press the update button on the list of open
invoices.
When the Update button is pressed on a form, show the frmNameUpdate for
the selected row (here we are selecting row 1) as shown in Figure 83 :
 
Search JabSto ::




Custom Search