Inserting path into table

tb5038

Registered User.
Local time
Today, 14:19
Joined
Jan 6, 2014
Messages
32
Hi,

I have a table named tbl_imagepaths with fields:

ImageID
File
Folder


The command button has the code below, it works great and pops up with a window with the file name and path. I now just need the code to insert the file name and path into the table.... Can anyone help

Code:
Private Sub Toggle7_Click()

    Dim f As Object
    Dim strFile As String
    Dim strFolder As String
    Dim varItem As Variant

    Set f = Application.FileDialog(3)
    f.AllowMultiSelect = True
    If f.Show Then
        For Each varItem In f.SelectedItems
            strFile = Dir(varItem)
            strFolder = Left(varItem, Len(varItem) - Len(strFile))
            MsgBox "Folder: " & strFolder & vbCrLf & _
                "File: " & strFile
        Next
    End If
    Set f = Nothing
End Sub


Thanks again
 
Something like..
Code:
Private Sub Toggle7_Click()

    Dim f As Object
    Dim strFile As String
    Dim strFolder As String
    Dim varItem As Variant

    Set f = Application.FileDialog(3)
    f.AllowMultiSelect = True
    If f.Show Then
        For Each varItem In f.SelectedItems
            strFile = Dir(varItem)
            strFolder = Left(varItem, Len(varItem) - Len(strFile))
            MsgBox "Folder: " & strFolder & vbCrLf & _
                "File: " & strFile
        Next
    End If
[COLOR=Red][B]    Me.FileFieldName = strFile
    Me.FolderFieldName = strFolder[/B][/COLOR]
    Set f = Nothing
End Sub
This is by the assumption, the Form is bound to the table.
 
Thanks Paul...

That worked great.... I can now see my file name and folder as hyperlins in the table. One other question, how would I combine both so I can give the complete path? Im hpping when I click the link it will start the file and associated program.

Many thanks, its such a small thing but so satisying when you get it working!
 
Most welcome. To get the file open on click you can use something along the lines of..
Code:
FollowHyperlink Me.FolderFieldName & Me.FileFieldName
[COLOR=Green]'If the Folder does not end with a Trailing slash use the following
'FollowHyperlink Me.FolderFieldName & "\" & Me.FileFieldName[/COLOR]
Good Luck !
 
Thanks... would I put that code undera button on the form? I was thinking about this just and im thinking of a continuous form with a couple of fields for date and description then a button at the end to lauchthe file.

Thanks
TJ
 
You can do that, i.e by adding a button ! Or you can just make it simple, by making the control mimic a Hyperlink and on click do the code.
 
Hi....

Im back, I've tried the code and Im getting a runtime error

Here's the code I'm using

Private Sub LoadImage()
FollowHyperlink Me.Folder, Me.File
End Sub

I've attached an image of the run time error too, its a problem with the # tags and for some reason I have a http:// added too.

Nearly there but not quite yet!
 

Attachments

  • runtime error 7971.png
    runtime error 7971.png
    12.5 KB · Views: 172
im so proud!

Ive solved it! Changed the field from hyperlink to text got rid of those ##'s and then used this code

FollowHyperlink Me.Folder & Me.File

Only I do get a microsoft office warning about a trustworthy source and would I like to open the file... If i could get rid of this that would be great!
 

Users who are viewing this thread

Back
Top Bottom