R
Richard Horne
Hi guys, as the title suggests I need to be able to refresh a form (or in
this case 10 sub forms) automatically after a certain time period as well as
constantly throughout the day, i.e. every 1 minute. I also need the form to
remember which field the user was typing in before the refresh occurs (if
they were) and return the cursor to the exact same place - uninterrupted.
After posting in another forum I was told to try the following code, but
this doesn't seem to work 100% i often get an error saying Field not found
[Tel ID] - Tel ID is the autonumber used to return to that current record
after the requery - I have no idea why this error occurs as all the sub form
have a field called Tel ID.
Private Sub Form_Timer()
Dim rst As DAO.Recordset
Dim lngID As Long
Dim CurCtl As String
If IsNull(Me.CustomerID) = True Then
Exit Sub
Else
CurCtl = Me.ActiveControl.Name
lngID = CustomerID
Me.Requery
Set rst = Me.RecordsetClone
rst.FindFirst "[CustomerID] = " & lngID
If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark
DoCmd.GoToControl CurCtl
Me.ActiveControl.SetFocus
End If
rst.Close
Set rst = Nothing
End If
End Sub
To explain this in the context of which it will be used, the system is a
telephone call log system split into a front and a back end, I need the forms
to refresh every minute to load in any new telephone calls for each persons
inbox, but as they may very often be typing in data at the moment of the
refresh I need their current position with a record to be remembered.
Please help!
this case 10 sub forms) automatically after a certain time period as well as
constantly throughout the day, i.e. every 1 minute. I also need the form to
remember which field the user was typing in before the refresh occurs (if
they were) and return the cursor to the exact same place - uninterrupted.
After posting in another forum I was told to try the following code, but
this doesn't seem to work 100% i often get an error saying Field not found
[Tel ID] - Tel ID is the autonumber used to return to that current record
after the requery - I have no idea why this error occurs as all the sub form
have a field called Tel ID.
Private Sub Form_Timer()
Dim rst As DAO.Recordset
Dim lngID As Long
Dim CurCtl As String
If IsNull(Me.CustomerID) = True Then
Exit Sub
Else
CurCtl = Me.ActiveControl.Name
lngID = CustomerID
Me.Requery
Set rst = Me.RecordsetClone
rst.FindFirst "[CustomerID] = " & lngID
If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark
DoCmd.GoToControl CurCtl
Me.ActiveControl.SetFocus
End If
rst.Close
Set rst = Nothing
End If
End Sub
To explain this in the context of which it will be used, the system is a
telephone call log system split into a front and a back end, I need the forms
to refresh every minute to load in any new telephone calls for each persons
inbox, but as they may very often be typing in data at the moment of the
refresh I need their current position with a record to be remembered.
Please help!