Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image frame - Calling the picture

Status
Not open for further replies.

darinmc

Technical User
Feb 27, 2005
171
GB
Hi
I'm using this code in the form current event.

it seems to be working ok BUT it took a bit of playing around etc..
Has it been written correctly and most effectively, that is, is it best in form current?
AND
the error handling part?

Code:
Private Sub Form_Current()
On Error GoTo Err_DisplayImage

Dim stPathA As String
Dim stPathB As String
stPathA = "\\Lynxserver\lynx\EmpPhotos\" & Me.EmpRegNo & ".jpg"
stPathB = "\\Lynxserver\lynx\EmpPhotos\3b.jpg"

If Dir(stPathB) = "" Then
'Open Image
Me.ImageFrame.Picture = stPathB
Else
'Default Image
Me.ImageFrame.Visible = True
Me.ImageFrame.Picture = stPathA
End If
labelRegistration

'Exit_DisplayImage:
'ImageFrame = strResult
''Exit Function

Err_DisplayImage:
Select Case Err.Number
Case 2220 ' Can't find the picture.
Me.ImageFrame.Visible = False
'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 Sub

Thx
Darin
 
What is [blue]labelRegistration[/blue]?

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
I'd replace this:
If Dir(stPathB) = "" Then

with this:
If Dir(stPathB) [!]<>[/!] "" Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thx to both..
lblregistration just calls a procedure checking if the employee is working/past emp/ suspended etc

I did have <>, will change it back if it helps speed things up..

I'm assuming that its correct to have the displayimage in the form current.
Thx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top