Automatic folders

desireemm

Registered User.
Local time
Today, 12:51
Joined
Dec 30, 2003
Messages
64
is there a way to get access to automatically assign a folder or link a folder to an index field (primary key). The reason I am asking is because there is a form with hyperlinks these hyperlinks lead to a pdf document which I create manually and is incased in a folder. Each folder is named after the Employees badge name, I was wonder if there is a way to do this automatically, because there is a total of over 2000 employees. Can anyone help

thank you
 
Maybe this will help you solve the folder problem

The code below runs through the records in the employee_table and creates a folder for each employee. To test the code, you'll need a table called "employee_table" with a field called "badge_name".

You'll aslo need to set two references in the code editor: "Microsoft Scripting Runtime", and "Microsoft ActiveX DataObjects 2.x Library" (for ADO) or "Microsoft DAO 3.x Object Library" (for DAO).

Code:
Public Function make_Emp_folder(emp_badge_name)

    Dim fso As FileSystemObject
    Dim emp_Root As String, emp_FLDR As String

    Set fso = New FileSystemObject

    emp_Root = "C:\Employees"

    emp_FLDR = emp_badge_name

    If Not fso.FolderExists(emp_Root) Then
        fso.CreateFolder emp_Root
    End If

    If Not fso.FolderExists(emp_Root & "\" & emp_FLDR) Then
        fso.CreateFolder emp_Root & "\" & emp_FLDR
    End If

End Function

Public Function make_folders()

    Dim eRx As ADODB.Recordset 'If using ADO
    'Dim eRx as Recordset      'If using DAO
    
    Set eRx = CurrentProject.Connection.Execute("employee_Table")  'If using ADO
    
    'Set eRx = CurrentDb.OpenRecordset("employee_table")           'If using DAO
    
    Do Until eRx.EOF
        make_Emp_folder eRx("badge_name")
        eRx.MoveNext
    Loop

    eRx.Close
    Set eRx = Nothing

End Function

Hope this is relevant. Good luck.
 
Adam

Thank you so much for helping me adam I sure do appreciate it. I need to donate to this forum its helped me alot in the past how can I go about doing that?? I'm going to be taking visual basic classes soon so I wont have to keep asking these questions. I've learned alot about databases and how powerful they are its to my benefit to learn visual basic also.

Thanks again Adam
 

Users who are viewing this thread

Back
Top Bottom