Link MS Project File to Form

carolanne1972

New member
Local time
Yesterday, 23:24
Joined
Aug 10, 2006
Messages
3
http://www.access-programmers.co.uk/...ad.php?t=97787

I am attempting to add a command button on a form that will allow user to browse files, then select a MS Project file to import, then have it linked to the current record (by a hyperlink or icon of some sort) so that clicking on it will open that MS Project file.

I found the above thread and have imported the modules and the fFindOpenImportFile in order to test in my database. I have made only slight alterations to the code, as I am still a novice w/ VB, but may not have done so correctly. In the Private Sub bImport_Click, I inserted 'tbFile' where sample "C:\Windows\Win.ini" had previously been, so that it will import the file already selected from the bBrowse_Click. (If there is a cleaner/better way to do this, I would appreciate any help.)

Here is an exceprt from the code:
Code:
Private Sub bImport_Click()
On Error GoTo Err_bImport_Click

    Me.tbHidden.SetFocus
    
    If IsNull(tbFile) Or tbFile = "" Then
        MsgBox "Please browse and select a valid file to import.", vbCritical, "Invalid File"
    Else
        If Dir(tbFile) <> "" Then
            CurrentDb().Execute "DELETE * FROM tImport"
            'FileCopy "C:\WINNT\Win.ini", "C:\WINNT\Win.txt"
            DoCmd.TransferText acImportDelim, , "tImport", "tbFile", False
            MsgBox "Your file has been imported into the Database."
        Else
           MsgBox "Your computer does not have a C:\Windows\Win.ini file so the import example will not work.", vbInformation
        End If
    End If
    
Exit_bImport_Click:
    Exit Sub

Err_bImport_Click:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_bImport_Click

End Sub

The imported form works great for 'Browse' or 'Open', but when I try 'Import', I get the following error:

2391- Field 'F1' doesn't exist in destination table 'tImport'

I even went back to the sample database and tested the form within the sample, using "win.ini" file and get the same error????:eek:

Of course, when I try it with an actual *.mpp file, I get this error:

31519- You cannot import this file.

...which leads me to believe that even if I fix the first error, I might be on the totally wrong path b/c it's an *.mpp file???:confused:

Any help would be greatly appreciated.

Thanks in advance for any help!
 
Last edited:
Ok, after doing some more research, I think my error has to do with the .mpp not being a text file, and the line of code that states "DoCmd.TransferText".

I do not want to import any of the actual data from the *.mpp files, just be able to add link/open file from within a form.

Many thanks for your time.
 
Open your form in design view.
Open the Properties window.
Select the Format tab page.
Set the property Is Hyperlink of your text box to Yes.
Add a Double Click Event to your text box, add code which is:

Code:
Application.FollowHyperlink Me.nameoftextbox

RV
 
Last edited:
Thank you all....
I gained many from this thread.....
 
RV-

Thank you so much! :) That is exactly what I was looking for- I knew there was a simple solution, but just couldn't seem to put my finger on it! I simply added a bound text box to my data form (so that I can store the file name after it is selected), added your instructions, and a command button with an adapted bBrowse_Click sub to browse for the .mpp file to 'attach'. (thanks to ghudson, the original poster of the sample database with this code, Browse [Find a directory or file]) It is working perfectly!

While I have been using this forum countless times over the last month to solve find solutions, this was my first attempt at utilizing any type of message board to post a specific question/problem, and am glad it was such a positive and helpful experience!
 

Users who are viewing this thread

Back
Top Bottom