Reputation: 1
hope this makes sense and that somebody can point me in the right direction. I am building a project in Access 2007
I have a table tblEmployees with a text field PhotoName, a form Form2 with a Listbox List0 and empty Image Boxes Image1 and Image2
Field PhotoName stores the name of a photograph i.e. 122000_998.jpg without the full path e.g. C:\Photos\122000_998.jpg
List0 has 4 columns of data with Column(4) being where the Photo filename is i.e. 122000_998.jpg
I need to select a photo from several rows automatically when Form2 opens
I can retrieve a Photo from any row to show in Image1 and Image2 using the following, but only if I change the Filename in tblEmployees PhotoNamI from 122000_998.jpg to C:\Photos\122000_998.jpg or if I change Me.Image1.Picture = Me.List0.Column(4) to Me.Image1.Picture = "C:\VisitorImage\" & Me.List0.Column(4)
Me.List0.Selected(0) =True
Me.Image1.Picture = Me.List0.Column(4)
Me.List0.Selected(1) =True
Me.Image2.Picture = Me.List0.Column(4)
How can add the path to the above to find the Photos when the above runs in the Form Open Event procedure without adding the path to tblEmployees PhotoName or adding it to each Line of code. I ask as the Path may change and it would be easier to simply change the path value rather than go througgh each line as there may be 20+ photos
All help appreciated, thanks
Jedski3
Upvotes: 0
Views: 1062
Reputation: 2085
How about?
dim pathprefix as String
pathprefix = "C:\Photos\"
Me.List0.Selected(0) =True
Me.Image1.Picture = pathprefix + Me.List0.Column(4)
Me.List0.Selected(1) =True
Me.Image2.Picture = pathprefix + Me.List0.Column(4)
Upvotes: 1