Solved

Search for files and save path name to MS-Access database table

Posted on 2014-11-22
2
951 Views
Last Modified: 2014-11-22
I have a client who is scanning employee vaccination records.  The client wants to store the location of the scanned form to  an immunization record.  How can I code it so when they click a button, a pop-up screen is opened to allow the user to browse for the image/document and save the path to the vaccination record?

Thanks

glen
0
Comment
Question by:GPSPOW
2 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 40459783
try this codes

Private Sub cmdAttachFile_Click()
Dim rsFile As DAO.Recordset
Dim strFilePath As String, strFilename As String
strFilePath = fSelectFile()
If strFilePath & "" <> "" Then
strFilename = Mid(strFilePath, InStrRev(strFilePath, "\") + 1)
    With CurrentDb.OpenRecordset("tblFileAttachments")
        .AddNew
        !RecordID = Me.txtMainID
        !FilePath = strFilePath
        !FileName = strFilename
        .Update
    End With
End If
End Sub

Function fSelectFile()
Dim fd As Object
Set fd = Application.FileDialog(3)
With fd
    .InitialFileName = CurrentProject.Path & "\"
    .AllowMultiSelect = False
    .ButtonName = "Select"
    .InitialView = 2
    .Title = "Select File"

    'display file dialog box
    If .Show Then
          fSelectFile = .SelectedItems(1)
    Else
        Exit Function
    End If

End With
End Function

Open in new window

0
 

Author Closing Comment

by:GPSPOW
ID: 40459850
Thank you

It worked perfectly.  I will just need to tweak the destination a little.

Glen
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now