Help with Images form

E

efandango

I have created a Table and Form in VBA to display an image. I used the
Microsoft Code example here:

http://support.microsoft.com/default.aspx?scid=kb;en-us;285820#appliesto


I followed the instructions exactly, cutting and pasting where relevant.

I now have a table linked to the correct path\filenames.

I Now have a form displaying the correct, 1st Image.

The problem is that the form will not let me advance to the next record. It
just won't budge. There are 80 records in the record selector on the form, as
is the table.

It won't let me go to design view, and when I close it, say's

"You can't save this record at this time."
"MS Access may have encountered an error..."

Has anyone else used this Microsoft example sucessfully?, or is there
something wrong with my code?

My Code for the VB module is:

Option Compare Database
Option Explicit

Public Function DisplayImage(ctlImageControl As Control, strImagePath As
Variant) As String
On Error GoTo Err_DisplayImage

Dim strResult As String
Dim strDatabasePath As String
Dim intSlashLocation As Integer

With ctlImageControl
If IsNull(strImagePath) Then
.Visible = False
strResult = "No image name specified."
Else
If InStr(1, strImagePath, "\") = 0 Then
' Path is relative
strDatabasePath = CurrentProject.FullName
intSlashLocation = InStrRev(strDatabasePath, "\",
Len(strDatabasePath))
strDatabasePath = Left(strDatabasePath, intSlashLocation)
strImagePath = strDatabasePath & strImagePath
End If
.Visible = True
.Picture = strImagePath
strResult = "Image found and displayed."
End If
End With

Exit_DisplayImage:
DisplayImage = strResult
Exit Function

Err_DisplayImage:
Select Case Err.Number
Case 2220 ' Can't find the picture.
ctlImageControl.Visible = False
strResult = "Can't find image in the specified name."
Resume Exit_DisplayImage:
Case Else ' Some other error.
MsgBox Err.Number & " " & Err.Description
strResult = "An error occurred displaying image."
Resume Exit_DisplayImage:
End Select
End Function

My Code for the Forms controls is:

Option Compare Database
Option Explicit

Private Sub Form_AfterUpdate()
CallDisplayImage
End Sub

Private Sub Form_Current()
CallDisplayImage
End Sub

Private Sub txtImageName_AfterUpdate()
CallDisplayImage
End Sub

Private Sub CallDisplayImage()
Me!txtImageNote = DisplayImage(Me!ImageFrame, Me!txtImageName)
End Sub
 

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