Delay navigation until image loads in vba

M

Mike B

I have an Access 2003 database where each record of the database is
displayed, added to, and edited on a form. One of the controls on the form
is an image box that is loaded from a directory containing all the images
for the database. One way of navigating thru the records is by clicking on
four navigation command buttons on the form.

My problem is that some of the image files are so large that the loading
takes a longer time than the operator can navigate to the next record. If
the operator keeps tapping the navigation controls looking for a particular
record, the image loading can't keep up, and this will eventually cause a
run time error. Is there a way to make vba wait for the image to complete
loading before leaving the loading subroutine and advancing to the
subroutine executing the navigation command? I know a delay routine could
be inserted but it isn't necessary for most of the images and I hate to slow
the whole program down for just a few images.

I don't know if it's helpful but the following loading takes place in
subForm_Current.

If IsNull(txtPhotoID) Then
' No image for this record.
cmdPixDelete.Visible = False
txtPhotoID.Visible = False
lblPhotoID.Visible = False
cmdPixLoad.Visible = True
Else
cmdPixLoad.Visible = False
On Error GoTo PixLoadError
imgPhoto.Picture = IMAGE_PATH & txtPhotoID & IMAGE_FILE_EXTENSION
Call AdjustTxtPhotoIDBoxWidth
txtPhotoID.Visible = True
cmdPixDelete.Visible = True
imgPhoto.Visible = True
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top