Navigation Pane Stopper

Navigation Pane Stopper

Here I demonstrate two methods of stopping the form being opened in the Navigation Pane.  The first method just stops the form being opened in the navigation pane and the second option only allows the form to be opened from an authorised form.

…         ..         ..            ..        ..          ..           ..     ..  ..         … 

First Method

This code stops a Form from being opened from the Navigation Pane. This Code prevents the user from opening a Form from the navigation pane. This is necessary if you have developed a Form which should only be open from another Form. In other words, a Form that passes information back to the Form that opened it.

The terms I use for these type of Forms are “Call Called” as in you have a Form which is “Called” (the one you are opening) and you have the Form that is being opened, that’s the “Called” Form >>> Call — Called. Adapted from a Microsoft Example HERE:- Application.CurrentObjectName Property (Access)

Private Sub Form_Open(Cancel As Integer)
'Application.CurrentObjectName Property (Access)
'HERE:-
'https://msdn.microsoft.com/en-us/library/office/ff196795.aspx
Dim strCurrentName As String
strCurrentName = Application.CurrentObjectName
    If strCurrentName = Me.Name Then
       Cancel = True
       Exit Sub
    End If
End Sub 'Form_Open

… …

Second Method

Here is another example demonstrating how to do something similar with the openargs event. This OpenArgs method is particularly useful because Instead of sending “Valid User” through you could, instead, send the name of the form that is doing the opening… Thus you could modify what your form does based on which form opened it.

Nicked from Microsoft – Form Object (Access)

The following example shows how to use the OpenArgs property to prevent a form from being opened from the Navigation Pane.

Private Sub Form_Open(Cancel As Integer)

If Me.OpenArgs() <> "Valid User" Then
    MsgBox "You are not authorized to use this form!", _
        vbExclamation + vbOKOnly, "Invalid Access"
    Cancel = True
End If
End Sub

… …