Hi,
I have created a macro AutoExec that run function InitApplication() automatically when database opens.
If I test by double click the macro AitoExec in Navigation Pane everything works fine. However if I close Access and double click the file in Explorer, it doesn't work.
Code:
Public Function InitApplication()
Dim lUnit As Long
DoCmd.OpenForm "FUser", , , , , acDialog
DoCmd.OpenForm "FMenu"
Form_FMenu.cboUnit.Value = 2
End Function
If I remove the last code, it works when I double click the file in Explorer.
Code:
Public Function InitApplication()
Dim lUnit As Long
DoCmd.OpenForm "FUser", , , , , acDialog
DoCmd.OpenForm "FMenu"
' Form_FMenu.cboUnit.Value = 2
End Function
I have tried to move the last code to Form_Open() of FMenu. It doesn't work when I double click the file in Explorer. Still works fine when I double click the macro AutoExec inside Navigation Pane.
Code:
Private Sub Form_Open(Cancel As Integer)
Me.cboUnit.Value = 2
End Sub