Question about "Current" and "Detail"

K

Kan D.

I have 2 fields plus a image in the my form's "Detail" section.

My Question:

How do I get the form to change the image path, based on some criteria (ie
one of the 2 field's value) for THAT RECORD ONLY?

In other words, when the form loads, I want to see

5 individual records, with 5 individual pictures (relating to that record),
based on the values of the fields within the individual record.

Do I do something with the "Current" event?

Thanks,
Kan
 
B

bob

You can display an image in the Access Image Control by handling the form’s ‘OnCurrent’ event to set the
‘Picture’ property of the image control to the path of the image file. Sample code and more info is available
below.

Unfortunately this doesn’t work in continuous forms – the OnCurrent event is only fired once, and not for
each record. One solution is to use an unbound form with a fixed grid of controls, then write code to
create a recordset and populate the controls a ‘page’ at a time.

Typical code for use in ‘Single Form’ mode (for Access 2k and later):

Private Sub Form_Current()
Dim ImagePath As String
ImagePath = GetImagePath & Me!Filename

If Len([Filename]) > 0 And Len(Dir(ImagePath)) > 0 Then
Image1.Picture = ImagePath
Else
Image1.Picture = ""
End If
End Sub

Public Function GetImagePath() As String
GetImagePath = GetDBPath & "images\"
End Function

Public Function GetDBPath() As String
GetDBPath = CurrentProject.Path & "\"
End Function


A more detailed explanation is available here:
http://www.ammara.com/access_image_faq/image_relative_paths.html

More information on continuous forms and possible alternatives is available here:
http://www.ammara.com/access_image_faq/image_continuous_forms.html
 
Top