Results 1 to 4 of 4
  1. #1
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79

    AutoExec

    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

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Set field value defaults in the form itself, under the Default Value property.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Forms!form!fmenu!cboUnit=2

    or set the combo value in the form that opens,not in the autoexec.

  4. #4
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79
    Hi,

    I tried to set Deafult value of combobox and it behved the same.

    I made a test and use the AutoAxec macro in a new file and it worked as it should. So it seems that my issue is a local error in my original file.

    Thanks for your response anyway.

    \Joakim

Please reply to this thread with any new information or opinions.

Similar Threads

  1. set warnings autoexec
    By bchi99 in forum Queries
    Replies: 6
    Last Post: 11-14-2014, 02:20 PM
  2. AutoExec
    By cbrsix in forum Programming
    Replies: 3
    Last Post: 06-21-2012, 11:49 AM
  3. Autoexec
    By Madmax in forum Programming
    Replies: 2
    Last Post: 07-12-2011, 11:33 AM
  4. AutoExec Mistake
    By HawkGuru in forum Programming
    Replies: 1
    Last Post: 04-23-2011, 04:48 AM
  5. Using parameter in autoexec macro
    By lchurch in forum Queries
    Replies: 0
    Last Post: 03-04-2009, 06:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums