Hello all
I'm trying to get a picture in a database so I can see on my form without bloating the database. This is what I have:
1st I have a folder called photos
2nd a table with one record, this being the path of the
folder (save people going into the code to change it)
3rd a frame (frame208) which asks "have photo yes / no"
4th a image frame to put the picture on the form
i've written the code below and call it in the afterupdate event of the frame and the on current event of the form.
the problem is that it loads all the pictures and not just the one I want?
Any ideas
Thanks
Mick
Private Sub loadpic()
On Error GoTo Err_loadpic
'check not a new record car not null
If Me![CARno] <> 0 Then
Dim strpath As String
Dim strfilename As String
Dim strlink As String
' get path from photolink table
strpath = DLookup("[photolink]", "[TBL photolink]")
' if check if picture is available
If Me![Frame208] = 1 Then ' 1 =yes
' get car number and consign it to path , set image frame to picture
strfilename = Me![CARno] & ".jpg"
strlink = strpath & strfilename
Me![Image220].Picture = strlink
Else
' set picture to no picture picture
strfilename = "no pic.jpg"
strlink = strpath & strfilename
Me![Image220].Picture = strlink
End If
End If
Exit_loadpic:
Exit Sub
Err_loadpic:
If Err.Number = 2220 Then
MsgBox "Photo was not found in the Photo directory!", vbInformation, "Photo not found."
Me![Frame208] = 2 ' 2= no photo
Else
MsgBox Err.Description
End If
Resume Exit_loadpic
End Sub
I'm trying to get a picture in a database so I can see on my form without bloating the database. This is what I have:
1st I have a folder called photos
2nd a table with one record, this being the path of the
folder (save people going into the code to change it)
3rd a frame (frame208) which asks "have photo yes / no"
4th a image frame to put the picture on the form
i've written the code below and call it in the afterupdate event of the frame and the on current event of the form.
the problem is that it loads all the pictures and not just the one I want?
Any ideas
Thanks
Mick
Private Sub loadpic()
On Error GoTo Err_loadpic
'check not a new record car not null
If Me![CARno] <> 0 Then
Dim strpath As String
Dim strfilename As String
Dim strlink As String
' get path from photolink table
strpath = DLookup("[photolink]", "[TBL photolink]")
' if check if picture is available
If Me![Frame208] = 1 Then ' 1 =yes
' get car number and consign it to path , set image frame to picture
strfilename = Me![CARno] & ".jpg"
strlink = strpath & strfilename
Me![Image220].Picture = strlink
Else
' set picture to no picture picture
strfilename = "no pic.jpg"
strlink = strpath & strfilename
Me![Image220].Picture = strlink
End If
End If
Exit_loadpic:
Exit Sub
Err_loadpic:
If Err.Number = 2220 Then
MsgBox "Photo was not found in the Photo directory!", vbInformation, "Photo not found."
Me![Frame208] = 2 ' 2= no photo
Else
MsgBox Err.Description
End If
Resume Exit_loadpic
End Sub