jesusoneez
IT Dogsbody
- Local time
- Today, 16:40
- Joined
- Jan 22, 2001
- Messages
- 109
I wasn't sure whether to post this in the form forum or here, but it's coding related to a form, so here I am.
I have a simple form that uses a combobox to select a student. Selecting the student autofills the txtStudentID text box. I have a picture box, and the form has some code;
Now, I know the above is wrong, but I don't know how to make it right. Not all the students have a photograph, so when you pick such a student, the error appears saying it can't find photo "C:\Pics\.jpg". For those that do have a photo, this works fine.
I know I want to say something like;
I just can't figure out the code to check the photo exists before assigning a value to the picture box (imgEmpty).
I should also point out that the photos are all named as their studentid, although that should be pretty obvious.
Any help much appreciated.
I have a simple form that uses a combobox to select a student. Selecting the student autofills the txtStudentID text box. I have a picture box, and the form has some code;
Code:
Private Sub Form_Current()
Me.imgEmpty.Picture = "C:\Pics\" & Me.txtStudentID.Value & ".jpg"
If Me.imgEmpty.Picture = ".jpg" Then
MsgBox "equals .jpg"
Else
MsgBox "Doesn't equal .jpg"
End If
End Sub
Now, I know the above is wrong, but I don't know how to make it right. Not all the students have a photograph, so when you pick such a student, the error appears saying it can't find photo "C:\Pics\.jpg". For those that do have a photo, this works fine.
I know I want to say something like;
Code:
Has the studentid got a photo?
if yes then the value of ImgEmpty is studentid plus .jpg
else display nothing (or display the picture blank.jpg)
I just can't figure out the code to check the photo exists before assigning a value to the picture box (imgEmpty).
I should also point out that the photos are all named as their studentid, although that should be pretty obvious.
Any help much appreciated.