Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2009
    Posts
    4

    Unanswered: Automatically Requering Forms

    I am having trouble getting the following code to work. I need this form to refresh every 30 seconds. It is being used in a manufacturing situation and I need to have this refresh automatically. Any suggestions would be grateful. I get this error see attachment
    Click image for larger version. 

Name:	error.gif 
Views:	12 
Size:	13.2 KB 
ID:	9513

    Private Sub Form_Open(Cancel As Integer)

    'When form opens, wait 30 seconds before
    'firing the Timer event
    Me.TimerInterval = 30000

    End Sub




    Private Sub Form_Timer()
    Dim intl As Long

    'Save value of primary key before requering
    int1 = Me.ProductionID
    'Turn off echo and requery
    DoCmd.Echo False
    Me.Requery

    'Move focus to primary key field and move to
    'record in field that was current before requerying:
    'turn echo back on
    Me.ProductionID.SetFocus
    DoCmd.FindRecord int1
    DoCmd.Echo True

    End Sub

  2. #2
    Join Date
    Mar 2009
    Posts
    5,441
    Provided Answers: 14
    If ProductionID is part of your form you should use
    Code:
    int1 = Me!ProductionID
    or
    Code:
    int1 = Me.ProductionID.Value
    It would be a good idea too to disable the timer when you enter the Timer function and re-enable it before leaving, mainly if the timer interval is short and the code that the timer triggers takes a long time to execute.
    Code:
    Private Sub Form_Timer()
    Dim intl As Long
    
    ' Disable the timer
    Me.TimerInterval = 0
    'Save value of primary key before requering
    int1 = Me.ProductionID
    ....
    ' Re-Enable the timer
    Me.TimerInterval = 30000
    
    End Sub
    Have a nice day!

Posting Permissions

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