Getting time since last restart in VBA of MS Access

Experts,

I'm looking for ways to retrieve time since last restart in VBA of MS Access.
If you can think of several ways to do it - please let me know.

Thank you.
LVL 1
PTishyn_comAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rockiroadsCommented:
what do you mean by restart of vba. Are you talking about the time your access db is started or when one goes to the vba window to do coding etc
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
"If you can think of several ways to do it "

Even ONE way would be cool, right ?

mx
0
rockiroadsCommented:
wotcha mx. PT, I would suggest a table which stores the time. Add in other attributes, say per user etc etc etc
Each time you start msaccess, you can run the Autostart macro to add in records

This way u have logged when db started. If you have or main menu/switchboard which is automatically started and db closes from that then you can control the login and logout times from here as well

when you login, u can query the db then calculate the date/time difference between that date and Now()
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

PTishyn_comAuthor Commented:
I apologize, I wasn't clear.
Time since the computer was restarted or, to be precise, when user logged on to Windows (not since Access was open).
0
rockiroadsCommented:
this code returns the date and time in one string

    Set objWMIService = GetObject("winmgmts://./root/cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem", , 48)
    For Each objItem In colItems
        strComputer = objItem.Name
    Next

    On Error Resume Next

    Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/cimv2")
    If Err.Number > 0 Then
        Debug.Print "Bugger, summat is messed up"
    Else
        Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem", , 48)
        For Each objItem In colItems
            Debug.Print objItem.LastBootUpTime
        Next
    End If


Its then a case of splitting it up
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rockiroadsCommented:
how to split up

        For Each objItem In colItems
            d = DateSerial(Left$(objItem.LastBootUpTime, 4), Mid$(objItem.LastBootUpTime, 5, 2), Mid$(objItem.LastBootUpTime, 7, 2)) & " " & TimeSerial(Mid$(objItem.LastBootUpTime, 9, 2), Mid$(objItem.LastBootUpTime, 11, 2), Mid$(objItem.LastBootUpTime, 13, 2))
            Debug.Print d
        Next

0
rockiroadsCommented:
by the way, this is time since pc boot up
0
PTishyn_comAuthor Commented:
Thank you very much.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.