dynamictiger
Registered User.
- Local time
- Today, 12:30
- Joined
- Feb 3, 2002
- Messages
- 270
To say this issue is difficult to describe is an understatement. To explain how the form and subforms work is even more difficult, but I will try.
I have a form, which is resident to a master subform. The master subform contains 5 other subforms. I tired the traditional approach of querying the form with a search combo box and then requerying the source objects and this was too slow, even on my development machine which would have meant my users machines would have been so slow as to be ridiculous. So I opted for links methods instead.
This works by having two hidden text fields on the master subform. All the subforms on the master are linked to the unbound hidden text fields. This resulted in an increase in speed of between two and fifteen times in loading. So far so good.
I have been working on the code behind the forms and noticed that many of the subforms are reloading more than once in the search. That is that the sub sub forms may have some code in the current event to do something. This code runs several times depending on the subform. I think this is inefficient but do not see how to stop it. A typical block of code is shown below:
Some of these calls are six or seven times, although the code they run is not that much it is still annoying. I would like to control the number of times the code runs or move the code to a more appropriate place in the forms to prevent it running so many times.
So far I have tried setting module level global but this seems to reset between calls, so does not work. I was thinking about setting database level global but then I am concerned that if I set them incorrectly the whole application won’t work. So now I have decided the events are in the wrong place. Which event should I use to prevent this problem?
I have a form, which is resident to a master subform. The master subform contains 5 other subforms. I tired the traditional approach of querying the form with a search combo box and then requerying the source objects and this was too slow, even on my development machine which would have meant my users machines would have been so slow as to be ridiculous. So I opted for links methods instead.
This works by having two hidden text fields on the master subform. All the subforms on the master are linked to the unbound hidden text fields. This resulted in an increase in speed of between two and fifteen times in loading. So far so good.
I have been working on the code behind the forms and noticed that many of the subforms are reloading more than once in the search. That is that the sub sub forms may have some code in the current event to do something. This code runs several times depending on the subform. I think this is inefficient but do not see how to stop it. A typical block of code is shown below:
Code:
Private Sub Form_Current()
Debug.Print "Form_Current.Start"
On Error Resume Next
Dim lngPoolID As Long
Call UpdateLink
lngPoolID = Me.PoolID
Me.txtHiglight.FormatConditions(0).Enabled = True
Me.txtHiglight.FormatConditions(0).Modify acExpression, acEqual, "[PoolID]= " & lngPoolID
Me.txtHiglight.FormatConditions(0).Enabled = False
Debug.Print "Form_Current.End"
End Sub
Some of these calls are six or seven times, although the code they run is not that much it is still annoying. I would like to control the number of times the code runs or move the code to a more appropriate place in the forms to prevent it running so many times.
So far I have tried setting module level global but this seems to reset between calls, so does not work. I was thinking about setting database level global but then I am concerned that if I set them incorrectly the whole application won’t work. So now I have decided the events are in the wrong place. Which event should I use to prevent this problem?
Last edited: