Results 1 to 6 of 6

Thread: AutoExec Macro.

  1. #1
    JamesP
    Guest

    AutoExec Macro.

    Hi
    I am attempting to us a Run Code AutoExec Macro and am having a hard time getting it to run.
    How do I call a sub from a module from the Macro. I used the builder in the space provided below says function name and it didn't seem to work when I created the code in a sub of function. Here is the code I wish to use:
    Public Sub OpenInformation()

    Dim SQLstr As String
    Dim db As Database
    Dim rsTemp As Recordset

    SQLstr = "SELECT tblOpen.AccessNum, tblOpen.AccessBy," _
    & "tblOpen.AccessTime, tblOpen.AccessDate" _
    & " FROM tblOpen;"
    Debug.Print SQLstr
    Set db = CurrentDb()
    Set rsTemp = db.OpenRecordset(SQLstr)


    With rsTemp
    .AddNew
    !AccessBy = Api_Calls.fOSUserName
    !AccessDate = Date
    !AccessTime = Time
    .Update
    .close
    End With

    I am using Access 97.

    Thanks! :]

  2. #2
    JamesP
    Guest

    Run code on database close?

    OOPS [img]/w3timages/icons/blush.gif[/img]

    I figured it out. Feel kind of silly that I missed it before.
    While I am here though, is there any way to run an event when the user closes the database so I can keep track who and how long they have accessed the data base?

    Thanks again :]

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run code on database close?

    Take a look at Tools, Startup.
    There you can specify a startup form.
    In the on open event of the form you can do all the things you want to do.
    I hate macros, the autoexec macro included!
    People of access, use VBA, make modules!

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Run code on database close?

    I agree. I rarely use AutoExec macros, usually only when I'm prototyping and not always even then. I prefer to launch a form to give the user something to look at and have the startup code called from it. The only macro I really use is AutoKeys.
    Charlotte

  5. #5
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run code on database close?

    There is no event (that I know of) for the closing of the database. However if you open a form on startup that is hidden you may be able to get the OnClose event for it when Access forces it to close and at that point write the closing time/duration to a table (or file). If that doesn't work then how are your coding skills? Could you write an app to start the database and then track how long the process exists.

  6. #6
    JamesP
    Guest

    Re: Run code on database close?

    Hi and thanks for all the good information. [img]/w3timages/icons/yep.gif[/img]

    Okay! I will rethink my Macro! :] I have a form that is executed at start up that could call the code, silly of me not to think of that.[img]/w3timages/icons/blush.gif[/img]

    Andy
    Your Idea sounds great! I will attempt it and see if it works! I don

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •