AllExperts > Using MS Access 
Search      
Using MS Access
Volunteer
Answers to thousands of questions
 Home · More Using MS Access Questions · Answer Library  · Encyclopedia ·
More Using MS Access Answers
Question Library

Ask a question about Using MS Access
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
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).

 
   

You are here:  Experts > Computing/Technology > Business Software > Using MS Access > record lock timeout

Using MS Access - record lock timeout


Expert: Rob Henderson - 2/9/2005

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?

rob

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.