Linking photos to a form/ text box???

joolsUK0575

Registered User.
Local time
Today, 16:10
Joined
May 6, 2004
Messages
49
Hi there

I am trying to link in photos to a database but I do not want to create them as OLE objects within the database.

I have seen on a database somewhere where you press a button and it opens up a box the same as if you were browsing for a file in windows. You then choose the file you wish to link in and it places the file path into a text box/ unbound box.

The last stage is to have a button that you click and it opens up the file in the default image viewer such as Microsoft Photo Editor.

Has anyone else seen this done and do they know how to do it?

I am working on a database for a work colleague and would dearly love to put this feature in to place.

Thanks for any help

Jools
 
Image Field and Forms

You can use this

Sub getFileName()
' Displays the Office File Open dialog to choose a file name
' for the current record. If the user selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer
With Application.FileDialog(msoFileDialogFilePicker)
.title = "Select Picture"
.Filters.Add "All Files", "*.*"
' .Filters.Add "JPEGs", "*.jpg"
' .Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.Path & "\images\"
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![image].Visible = True
Me![image].SetFocus
Me![image].Text = fileName
Me![otherfield].SetFocus
Me![image].Visible = False
End If
End With
End Sub

NB you probably want a few buttons to only show the images when requested to do so as it will slow any database down a lot.

You can in the Form OnCurrent Event set a message caption to say "Select to show" or "Image required" or "Water is wet" dependant on whether the image field is null.
 
Erm. Lost, totally!

I'll explain again in a little more detail (hopefully not upsetting the kind souls that have already posted)

I have a form say for example "main". On this form is a button that will open the MS Windows dialog box to open a file.

Once "open file" is clicked it will then place the path to the image in a field entitled "imagepath".

I also need a button that will open the image file back up again in the default image viewer.

So, when creating the button to open the windows dialog box what code do I out in? I have right clicked the properties of the button and gone to "code builder" which now presents me with the following:

Private Sub openfile_Click()

End Sub

What is it that I put in between these bits of code?

And lastly what do i need to put in on a seperate button to open the image in the default image viewer:

Private Sub openimage_Click()

End Sub

Thanks. Sorry for this :confused:

Jools
 
Hi there

Thanks for the reply.

That is "nearly" there, but it is not what I am after.

If you look at my second post that is what I after. Not sure how to explain it better :(

Jools
 

Users who are viewing this thread

Back
Top Bottom