04-21-11, 15:18 #1Registered User
- Join Date
- Jun 2010
Unanswered: Access 2007 timer interval - lowest/fastest setting
I'm collecting some data on Form 1, and a minimized Form 2 populates with this information on Form_Current then closes Form 2 and Form 1 on timer interval 1000. I need to speed it up a bit.
Form 2 is opening to a new record after update of the last field in Form 1....seems instantaneous (word?), but are there certain intervals that have to be allowed to carry out the event in Form_current?
This can literally be behind the scenes - very quick...as long as Form 2 gets it's data
04-22-11, 01:15 #2Moderator
Provided Answers: 19
- Join Date
- Jun 2005
- Richmond, Virginia USA
It might help if you tried to explain what is meant by
"...there certain intervals that have to be allowed to carry out the event in Form_current"
Linq ;0)>Hope this helps!
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007
04-22-11, 03:42 #3Moderator
Provided Answers: 14
- Join Date
- Mar 2009
Generally speaking it's never a good idea to rely on a Timer to (try to) control interactions between Forms.
Access is an Events driven system and you cannot simply assert that something on a Form (e.g. the completion of a function, VBA or internal) will be in a certain state after a certain amount of time.
If you need such a control in your application you can use specific events you create with the RaiseEvent statement. A very simple way of achieving this consists in creating a Class that will be shared among several objects (Forms, Reports, other classes, etc.) and that will act as a shuttle to relay signals among these objects.
Here's an example of this method. It does not perform anything useful but helps to understand how the technique works. In reality this class has many other properties and methods that are not present here.
Option Compare Database Option Explicit ' ' *************************** ' *** Class Cls_DataArray *** ' *************************** ' ' This class is used to carry data among several objects. ' ' Each object using it has a pointer on the same instance of the class. ' Private Type DataArray Value As Variant Name As String Type As Long End Type Public Event DataLoaded() Private m_varArray() As DataArray Private m_lngMaxIndex As Long Private m_booAllowNull As Boolean Private m_booDirty As Boolean Public Function Load(rst As DAO.Recordset) As Long Dim i As Integer With rst m_lngMaxIndex = .Fields.Count - 1 ReDim m_varArray(-1 To m_lngMaxIndex) If (.BOF And .EOF) = False Then .MoveFirst For i = 0 To m_lngMaxIndex m_varArray(i).Value = .Fields(i).Value m_varArray(i).Name = .Fields(i).Name m_varArray(i).Type = .Fields(i).Type Next i Else For i = 0 To m_lngMaxIndex m_varArray(i).Value = Null m_varArray(i).Name = .Fields(i).Name m_varArray(i).Value = .Fields(i).Type Next i End If End With m_booDirty = False Load = i RaiseEvent DataLoaded End Function
Private m_clsDataArray As Cls_DataArray Set m_clsDataArray = New Cls_DataArray
Private m_Form2 As Form DoCmd.OpenForm "Form2" Set m_Form2 = Forms("Form2") m_Form2.Initialize m_clsDataArray
Private m_clsDataArray As Cls_DataArray
Set m_clsDataArray = DataArray m_clsDataArray.Load Me.RecordsetClone
Private WithEvents m_clsDataArray As Cls_DataArray
Public Function Initialize(ByVal DataArray As Cls_DataArray) Set m_clsDataArray = DataArray End Function
When the event DataLoaded is raised by the instance of the class Cls_DataArray, the signal is received by Form3, like this:
Private Sub m_clsDataArray_DataLoaded() ' Process the data in Cls_DataArray End SubHave a nice day!