Share via

Code doesn't work on Access 2016 Form

Anonymous
2023-07-19T12:45:43+00:00

This is the error I get when I try to run the Click Event below. How can I get this code, and I assume all the rest of the code in this book,, to run?

I am running a Windows 11 Pro 64-bit machine.

Herer is all of the code for this event:

Private Sub cmdGo_Click()

Dim i As Integer

Dim j As Integer

Dim snExplicit As Single

Me.txtImplicitStart.Value = GetTickCount()

For o = 1 To 10000

For p = 1 To 10000 

  q = i / 0.33333 

Next p 

Next o

Me.txtImplicitEnd.Value = GetTickCount()

Me.txtImplicitElapsed.Value = _

Me.txtImplicitEnd.Value - Me.txtImplicitStart.Value 

DoEvents 'Force Access to complete pending operations

Me.txtExplicitStart.Value = GetTickCount()

For i = 1 To 10000

For j = 1 To 10000 

  snExplicit = i / 0.33333 

Next j
Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2023-07-19T13:15:25+00:00

Look for a line of code near the top of a module that looks like this:

Declare Function GetTickCount Lib "kernel32.dll" () As Long

The word Declare might be preceded by Public or Private.

Insert the word PtrSafe between Declare and Function:

Declare PtrSafe Function GetTickCount Lib "kernel32.dll" () As Long

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2023-07-19T17:44:23+00:00

    Yep it works. Thank you VERY much.

    Was this answer helpful?

    0 comments No comments