Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

print picture on form 1

Status
Not open for further replies.

ecalbert

Programmer
Dec 25, 2004
61
IL
I have pictures all saved as teh filename the same as my id in a database.
Is there anyway I can show them on my access form when I browse the record?
 
ecalbert
Take a look at the Northwind sample database that comes with Access, and see how it was done there.

Tom
 
If you have stored images extension too then you can use the code below on current event of the form. You can't use it in a continues form.
Code:
Private Sub Form_Current()
   [COLOR=green] 'dim variables[/color]
    Dim folderpath, fullpath, ImageName

[COLOR=green]    'find application full path[/color]
    fullpath = CurrentProject.FullName

    [COLOR=green]'find folder path[/color]
    folderpath = Left(fullpath, InStrRev(fullpath, "\") - 1)
    
   [COLOR=green] 'set image name with extension[/color]
    ImageName = Me.txtImageName.Value
    
    [COLOR=green]'capture new record error[/color]
    If Me.NewRecord Then
        Exit Sub
    Else
       [COLOR=green] 'set picture to the image[/color]
        Me.Image6.Picture = folderpath & "\" & ImageName
    End If
End Sub


________________________________________________________
Zameer Abdulla
Help to find Missing people
Do not cut down the tree that gives you shade.
 
Zameer, why not simply this ?
folderpath = CurrentProject.Path

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
well waht I really want to do is look at teh id of the entry and check the file pictures -- and if that id.jpg exists in the picture directory then I want to display it.
Which method do you suggest?
 
Have a look at the Dir function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV, thanks.. I totally forgot it.

________________________________________________________
Zameer Abdulla
Help to find Missing people
Do not cut down the tree that gives you shade.
 
sot to change it like
Code:
Private Sub Form_Current()
   [COLOR=green] 'dim variables[/color]
    Dim folderpath, ImageName
    
   [COLOR=green] 'find folder path[/color]
    folderpath = CurrentProject.Path
    
    [COLOR=green]'set image name with extension[/color]
    ImageName = Me.txtImageName.Value
    [COLOR=green]
    'capture new record error
[/color]    If Me.NewRecord Then
        Exit Sub
    Else
       [COLOR=green] 'set picture to the image[/color]
        If Dir(folderpath & "\" & ImageName) = ImageName Then
        Me.Image6.Picture = folderpath & "\" & ImageName
        Else
        [COLOR=green]'set a nopicture image[/color]
        Me.Image6.Picture = folderpath & "\" & "NoPicture.jpg"
        End If
    End If
End Sub

________________________________________________________
Zameer Abdulla
Help to find Missing people
Do not cut down the tree that gives you shade.
 
hi thaks for your help -- I was away so didn't work on this for a while...
ZmrAbdullah -- where exactly do I put this code?
also how can I set the picture name to be from the table?
I have a filed in the table called id and hte picture name is always the id adn ".jpg"

Thanks for your help.
 
It is obvious as shown in the beginnig of the code
Code:
Private Sub Form_Current()

________________________________________________________
Zameer Abdulla
Help to find Missing people
Seek counsel of him who makes you weep, and not of him who makes you laugh.
 
thanks -- and how would I pull out the id from the table.
I appreciate your help - I don't know access very well.
 
You will have a textbox on the form called "ID"
Code:
ImageName = Me.txtImageName.Value
will be changed to
Code:
ImageName = Me.ID.Value



________________________________________________________
Zameer Abdulla
Help to find Missing people
Seek counsel of him who makes you weep, and not of him who makes you laugh.
 
thanks so much -- that worked!

Anyway I can set the size of Image6 to be whatever the size of the picture is vs. the size of the original Image6?
 
Look for "SizeMode Property" in the VBA help file.

________________________________________________________
Zameer Abdulla
Help to find Missing people
Seek counsel of him who makes you weep, and not of him who makes you laugh.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top