This pertains to embedding ESRI MapControls into Access Database Forms.
I have two access files, split into a frontend and backend. My backend is also a PersonalGeoDatabase that ArcGIS uses to store a feature class for display on a From embedded ESRI map control.
The feature class stores polylines, points, and polygons which are associated with a specific ProjectID.
From the frontend, I have the embedded mapControl which loads the MXD file tied to the backend.
I've got a VB function called CenterPoint, which coincidentally, centers the map envelope around the Project's associated feature class (if it exists) and sets the desired viewing extents. If the feature class for a project doesn't yet exist, it centers the map around the entire region all the projects are contained in, giving a general overview.
So, if that all made sense, and I haven't lost you...
I originally called the CenterPoint sub in the Form_Current Event. This worked, in that it performed all the functionality desired; however, while the CenterPoint function ran, the form was unresponsive, preventing changing to another record until the re-draw had finished. This meant, if you wished to jump through 10 records, you would have to jump 1, wait for re-draw, jump another, wait for re-draw, etc. I sped up the re-draw considerably by optimizing the MXD imagery and layers, but it was still unacceptable.
Next, I tried to establish a delay of a few seconds, before it called the CenterPoint sub by running the following:
Private Sub Form_Current()
Dim s_Start As single
Dim s_Delay As single
s_Start = Timer
Do While Timer < s_Start + s_Delay
DoEvents
Loop
CenterPoint
End Sub
Which gives me the desired responsiveness by using the DoEvents call, meaning I can click multiple records before it tries to re-draw the first time.
Unfortunately, it apparently cache's all the Form_Current calls, and if I skip say, 3 records, wait for the delay to end, and watch the screen, it will re-draw (ie. run CenterPoint) 3 times consecutively.
Even more weird, is it sporadically gives me a division by zero error for the line:
Do While Timer < s_Start + s_Delay
despite having no division in the line.
So, I guess my questions are:
- Is there a way to have access only run the form_current call once?
- If not, is there a way to make sure a user has stayed on the current record for a given time before I call the CenterPoint function?
- Is there a way to insulate my less-than comparison from the division by zero error, so at least, even though it will re-draw multiple times, the user can click through records in rapid succession?
Right now, my work around has been to put the CenterPoint sub as a click event for a button on the form, which works, but isn't ideal.
If any of this doesn't make sense, or more information is necessary, please let me know.
Thanks, Spencer