Can Access "on open" go to a certain form?

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,341
Office Version
  1. 365
Platform
  1. Windows
Can Access "on open" go to a certain form and Hide Navigator?

Form: EZStartUp
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
I would think from the autoexec you could launch that
 
Upvote 0
Yes and a lot more.
You can use an autoexec or hidden form.

I chose a form for one DB and this in the open event I decide which form to open depending on the type of user..

HTH

Code:
Option Compare Database
Option Explicit
Public dbPA As DAO.Database
Public rsUser As Recordset


Private Sub Form_Close()
'    MsgBox rsUser.Fields("Full_Name")
' Now we clear the logged in flag to identify anyone left logged in when tring to update/amend the back end.


With rsUser
    .Edit
    .Fields("Logged_in").Value = False
    .Update
End With


rsUser.Close
Set rsUser = Nothing
Set dbPA = Nothing
Application.Quit acQuitSaveAll
End Sub


Private Sub Form_Open(Cancel As Integer)
'This form will control what form will be used as startup depending on the user name (FileID) in Windows.
' If an FL, they will get the control form, if PA, just the allocation form


Dim strOpenForm As String, strSQL As String, strUser As String, strRole As String, blnFlow_Leader As Boolean
Dim intRecordCount As Integer
Dim strReqPath As String


On Error GoTo Err_Handler


strReqPath = "C:\Program Files\PA Allocation"


'First make sure user is running their own accde file on their computer


If InStr(CurrentProject.Name, "accde") > 0 Then
    If CurrentProject.Path <> strReqPath Then
        MsgBox "Incorrect database opened, this will now close"
        Application.CloseCurrentDatabase
    End If
Else
    MsgBox "WARNING - This is not the accde file"
End If


'Using the TempVar collection for any global variables


TempVars("G_File_ID").Value = Environ("USERNAME")
TempVars("G_Full_Name").Value = ""




strUser = TempVars("G_File_ID").Value




strSQL = "SELECT User.Full_Name, User.Role,User.Flow_leader, User.Logged_In FROM User WHERE  (((User.File_ID)='" & strUser & "'));"


'MsgBox strSQL


Set rsUser = CurrentDb.OpenRecordset(strSQL)
' If no record found then EOF is true


If Not rsUser.EOF Then
    intRecordCount = rsUser.RecordCount
    TempVars("G_Full_Name") = rsUser.Fields("Full_Name").Value
    strRole = rsUser.Fields("Role").Value
    blnFlow_Leader = rsUser.Fields("Flow_Leader").Value
  Else
    MsgBox "Unable to locate User for User ID " & strUser
    Exit Sub
End If


' Now we set the logged in flag to identify anyone left logged in when tring to update/amend the back end.
With rsUser
    .Edit
    .Fields("Logged_in").Value = True
    .Update
End With




'Recordset and database now closed in Close event when database closes
' rsUser.Close
' Set rsUser = Nothing
' Set dbPA = Nothing


' Cancel opening of this form
' Cancel = True


' Now we open specific form


If intRecordCount > 0 Then
    If strRole = "FL" Then
        strOpenForm = "FL_Control"
    Else
        If strRole = "PA" Then
            strOpenForm = "PA_Work_Allocation"
        Else
            strOpenForm = "FT_Work_Allocation"
        End If
    End If
    
End If


DoCmd.OpenForm strOpenForm


Err_Exit:
    Exit Sub
    
Err_Handler:
    MsgBox "Error " & Err.Number & " " & Err.Description
    Resume Err_Exit
End Sub
 
Last edited:
Upvote 0
If you mean on opening a specific database, the options menu for the database lets you set all that.
 
Upvote 0

Forum statistics

Threads
1,214,959
Messages
6,122,476
Members
449,087
Latest member
RExcelSearch

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top