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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting file properties 1

Status
Not open for further replies.

orionsong

Programmer
May 8, 2000
34
0
0
MY
I wonder if there is a way to automatically fill in a field automatically. I am working on an image catalogue. Instead of typing in the pathname and the file size of an image. I would like to browse for the file on my pc through the form and when i click on the file, it would automatically fill in the pathname field and the filesize field on the form.

Any help or pointers is greatly appreciated.
 
You can use a Windows Common Dialog Box call to get Windows Standard Directory window, and when they click ok (or open, can't remember which) it will return the path and file name. The following code is from Access 97 Developer's Handbook by Litwin, Getz and Gilbert (SYBEX) and makes the function call. Hopefully you can get enough information out of it to use, otherwise, I suggest buying the book.
Code:
Sub TestGetFileName()
    ' From Access 97 Developer's Handbook
    ' by Litwin, Getz, and Gilbert (Sybex)
    ' Copyright 1997.  All rights reserved.
    
    Dim gfni As adh_accOfficeGetFileNameInfo
    With gfni
        .hwndOwner = Application.hWndAccessApp
        .strAppName = "Delete Extra HTML"
        .strDlgTitle = "Select an HTML File"
        .strOpenTitle = "Select"
        .strFile = ""
        .strInitialDir = "C:\Windows\Temporary Internet Files\Cache1"
        .strFilter = "HTML (*.html;*.htm)|HTM Files (*.htm)|HTX Files (*.htx)|All Files (*.*)"
        .lngFilterIndex = 1
        .lngView = adhcGfniViewList
        .lngFlags = adhcGfniNoChangeDir Or adhcGfniInitializeView
    End With
    If adhOfficeGetFileName(gfni, True) = adhcAccErrSuccess Then
        MsgBox "You chose: " & Trim(gfni.strFile), vbOKOnly, "Test Get File Name"
    End If
End Sub
Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
Thanks, by using search here, i've found possible solutions to the file pathname. I've listed the titles below.

Results of the search are:
"Use form to browse drives" and another one using Common window dialog box you mentioned. It was by Elizabeth.

However, there is still no solution that covers the file size part of my question. Thanks for replying. :)
 
Once you get the file name, use the FileSystemObject to get the size.

Dim fso as object
Dim lngSize as long
Set fso = CreateObject("Scripting.FileSystemObject")
lngSize = fso.getFile(strFilename).size
Set FSo = nothing

Requires SCRRUN.DLL (Scripting on your machine)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top