About Rob Henderson Expertise I can answer most MS Access design questions. I also welcome questions on database design and implementation and VBA programming questions.
I also have expierence in application design for all the Office components (Excel, Outlook, etc).
Question Here is my code to set a record lock timeout on a form. Why do I get the following. The event procedure is On Timer and the interval is set to 1000:
THE EXPRESSION ON TIMER YOU ENTERED AS THE EVENT PROPERTY SETTING PRODUCED THE FOLLOWING ERROR: METHOD OR DATA MEMBER NOT FOUND.
*THE EXPRESSION MAY NOT RESULT IN THE NAME OF A MACRO, THE NAME OF A USER DEFIND FUNCTION, OR [EVENT PROCEDURE]
*THERE MAY HAVE BEEN AN ERROR EVALUATING THE FUNCTION, EVENT OR MACRO.
Option Compare Database
Option Explicit
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
' Record lock timeout time in seconds
Private Const conMaxLockSeconds As Integer = 60
Sub cmdClose_Click()
DoCmd.Close
End Sub
Private Sub Form_Timer()
Dim intElapsed As Integer
Dim strMsg As String
Dim ctlmsg As Control
Static slngTimerStart As Long
Static sblnDirty As Boolean
If Me.NewRecord Then
Exit Sub
End If
Set ctlmsg = Me.txtMessage
If Me.Dirty Then
' Record has been modified since last save
If sblnDirty Then
' Elapsed time may be over one minute, so
' grab both the minutes and seconds portion
' of the elapsed time
intElapsed = (timeGetTime - slngTimerStart) \ 1000
If intElapsed < conMaxLockSeconds Then
' Update message control with remaining time
strMsg = "Edit time remaining: " _
& (conMaxLockSeconds - intElapsed) & " seconds."
ctlmsg = strMsg
If intElapsed > (0.9 * conMaxLockSeconds) Then
ctlmsg.ForeColor = vbRed
End If
Else
' Timeout user and undo changes
ctlmsg = ""
ctlmsg.ForeColor = vbBlack
Me.Undo
sblnDirty = False
MsgBox "You have exceeded the maximum record lock period (" & _
conMaxLockSeconds & " seconds). " & vbCrLf & vbCrLf & _
"Your changes have been discarded!", _
vbCritical + vbOKOnly, "Record Timeout"
End If
Else
' Start timing the edits
slngTimerStart = timeGetTime
sblnDirty = True
End If
' Record has not been modified since last save
Else
If sblnDirty Then
' User has saved changes, so stop timer
sblnDirty = False
ctlmsg = ""
End If
End If
End Sub
Answer Hi
I have a few thoughts on this.
1. What line is the error kicking in?
2. If you used error checking you may get a more accurate error handle
3. I note that you've not killed the timer while you execute this code (Me.TimerInterval=0) - could that be reason?