Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6967993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:23:37+00:00 2026-05-27T16:23:37+00:00

I got this code for measuring the time of a query in Access database.

  • 0

I got this code for measuring the time of a query in Access database. Every time I try to run it, I get syntax error and MyTest() line is highlighted.

Option Compare Database

Option Explicit

Private Declare Function timeGetTime _
Lib "winmm.dll" () As Long
Private mlngStartTime As Long

Private Function ElapsedTime() As Long
ElapsedTime = timeGetTime() - mlngStartTime
End Function

Private Sub StartTime()
mlngStartTime = timeGetTime()
End Sub

Public Function MyTest()

Call StartTime
DoCmd.OpenQuery "Query1"
DoCmd.GoToRecord acDataQuery, "Query1", acLast

Debug.Print ElapsedTime() & _

Call StartTime
DoCmd.OpenQuery "Query2"
DoCmd.GoToRecord acDataQuery, "Query2", acLast

Debug.Print ElapsedTime() & _
End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:23:38+00:00Added an answer on May 27, 2026 at 4:23 pm

    Here’s another alternative (old VB6/VBA – not VB.Net syntax).

    KEY SUGGESTION: the “_” characters are “continuation lines”. I honestly don’t think you want them in most of the places you’re using them.

    IMHO…

    Option Explicit
    
    Private Declare Function timeGetTime Lib "winmm.dll" () As Long
    Private startTime, endTime As Long
    
    Private Function elapsedTime(t1, t2 As Long) As Long
      elapsedTime = t2 - t1
    End Function
    
    Public Function MyTest()
    
      startTime = Now
      ' << do stuff >>
      endTime = Now
      MsgBox "Elapsed time=" & elapsedTime(startTime, endTime)
    
    End Function
    
    Private Sub Command1_Click()
      Call MyTest
    End Sub
    

    edited.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got this code for my sharepoint, but I get a Access is Denied,
I got this code in my submit form <form id=myform action='hello.php' method='GET'> <input type=button
I got this code snippet to copy a file database to a memory database.
I've got this code that uses winforms to get data passed between two forms
i got this code off the internet, i suppose to get a list of
I got this code from Andy Tanenbaum's book. I am trying to run it.
I got this code which address my Get the 1st image of the post
I got this code But I got the following errors: Error 1 Instance argument:
I got this code.. ..... try: task_db.cursor.execute('DROP TABLE IF EXISTS `tasks`') print Affected: %d
Got this code for a viewscroller from the apple developers site. @synthesize scrollView1, scrollView2;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.