SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot Paul_M's Avatar
    Join Date
    Mar 2001
    Location
    London
    Posts
    160
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Timing queries in MS Access

    Is it possible to time the execution of queries in MS Access? (Not using an external program)

    Thanks.

    P.S. No flames about how bad MS Access is and how serious developers don't use it - please

  2. #2
    SitePoint Guru asterix's Avatar
    Join Date
    Jun 2003
    Posts
    847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Paul_M
    Is it possible to time the execution of queries in MS Access? (Not using an external program)

    Thanks.
    Of course it is possible. And of course, some serious developers still use MS Access, they just don't use it for high concurrency applications.

    Code:
    Option Compare Database
      Private Declare Function timeGetTime Lib "winmm.dll" () As Long
      Dim lngStartTime As Long
      
      Private Sub StartTimer()
      	lngStartTime = timeGetTime()
      End Sub
      Private Function EndTimer()
      	EndTimer = timeGetTime() - lngStartTime
      End Function
      
      Private Function TimeSelectStar(TableName As String) As Integer
      Dim sSQL As String
      Dim rResult As Recordset
      	
      	SQL = "select * from " & TableName
      	
      	StartTimer
      	
      	Set rResult = DBEngine(0)(0).OpenRecordset(SQL)
      	While Not rResult.EOF
      		rResult.MoveNext
      	Wend
      	
      	
      	TimeSelectStar = EndTimer
      End Function
      
      Sub TEST()
      
      	MsgBox (TimeSelectStar("dbo_authors"))
      
      End Sub
    You paste this code into a new module.
    Then you change the name of the table you want to time in the TEST subroutine.

  3. #3
    SitePoint Zealot Paul_M's Avatar
    Join Date
    Mar 2001
    Location
    London
    Posts
    160
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Asterix.


Bookmarks

Posting Permissions

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