Hi,
I have a form which is used to enter user details. The form has a textbox that holds the name of an image and a picture that displays that image. In the oncurrent even of a form I havethe following code that tries to load an image with the name in the textbox and if this is an error (normally due to there being no image name) loads a default image.
The code works but a message box saying something to do with the image path flicks up momentarily. I cant read the exact message as it is too quick but I think it displays an error message that the image can't be found which is then cancelled over-ruled by the on error statement.
Is there a way to stop this message displaying?
I'm thinking check if the file exists before loading rather than relying on the error during loading to tell me the file doesn't exist.
This is the code I am currently using
I have a form which is used to enter user details. The form has a textbox that holds the name of an image and a picture that displays that image. In the oncurrent even of a form I havethe following code that tries to load an image with the name in the textbox and if this is an error (normally due to there being no image name) loads a default image.
The code works but a message box saying something to do with the image path flicks up momentarily. I cant read the exact message as it is too quick but I think it displays an error message that the image can't be found which is then cancelled over-ruled by the on error statement.
Is there a way to stop this message displaying?
I'm thinking check if the file exists before loading rather than relying on the error during loading to tell me the file doesn't exist.
This is the code I am currently using
Code:
'Get the path to the folder containing user images,
'this is a path relative to the location of the database
GetImagePath = CurrentProject.Path & "\EmployeeImages\"
DoCmd.SetWarnings False
'Try and load an image for the user
On Error GoTo NoImage
Me![EmployeePic].Picture = GetImagePath & Me![ImageName]
Exit Sub
NoImage:
'If no image exists load default
Me![EmployeePic].Picture = GetImagePath & "blank.jpg"
DoCmd.SetWarnings True
End Sub