Reading the name of f iles

daybase

New member
Local time
Today, 22:50
Joined
Dec 22, 2000
Messages
8
I have a database which holds details of graphic files and allows the user to view files. Due to the size and quantity of graphics I have opted against embedding the graphics but the table holds name of the file and uses that information to insert the graphic in the report or display on form. Works great but you have to type the filename correctly (obviously) for it to work. I would like to use the directory windows to find a file for inclusion but rather than load the file just read the file name for use in code or to populate the table. Can it be done and, if so, how? please keep it simple.
 
It is only necessary to place your question in one forum. Somebody will find you and answer your question! Just select the single forum that you think your query best fits in.
 
Apologies - didn't seem to fit properly anywhere
 
Not a problem. The reason for only putting a post in one forum is that someone may spend 20 minutes working on a reply to you to only find out, when looking at another forum, that you and someone else are already working on a solution.

Yep, sometimes it is hard to know where to place your question but the folks here usually look at all the forums so one of the experts will find you....

Jack
 
daybase,

Haven't tried it, but here is the general idea ...

Code:
Dim dbs As DataBase
Dim sql As String
Dim Filename As String

Set dbs = CurrentDb

FileName = Dir("C:\YourDirectory\*.jpg")
While (FileName <> "")
    sql = "Insert Into YourTable(YourFile) " & _
          "Values ('" & FileName & "')"
    dbs.Execute(sql)
    FileName = Dir
    Wend

Wayne
 

Users who are viewing this thread

Back
Top Bottom