Mkdir for all Employees

ECEK

Registered User.
Local time
Today, 13:11
Joined
Dec 19, 2012
Messages
717
I have 125 Employees in my Table and I would like to create a folder for each one.
I have a form with a command button that will create a directory for each employee individually.

Code:
MkDir "S:\Access\VBA\DATABASES\" & Me.Employee
What do I need to research in order to create a file for all the employees in one go?

Is this Looping?
 
open the recordset that contains
the employee information table.

dim rs as dao.recordset
set rs=currentdb.openrecordset("employeeTable",dbopensnapshot)
with rs
If not (.bof and .eof) then .movefirst
While not .eof
MkDir "S:\Access\VBA\DATABASES" & !employeeName 'or employeeID
.MoveNext
Wend
.Close
End With
Set rs=nothing
 
Short answer yes :)

Longer answer without writing it completely for you
Open a recordset of your employees
While Not EOF
Do your code
Move next
Loop
Close your recordset

Edit: Arne beat me to it - no fun. ;)
 
Thanks guys:
Arne I'm just struggling with this line: My Query holding my Employees names is called qryFolders

set rs=currentdb.openrecordset("qryFolders",dbopens napshot)

So I tried this:
Set rsQuery = dbs.OpenRecordset("qryFolders", dbOpenDynaset)
Still no luck !!

Edit:
The s napshot threw me.

Set rs = CurrentDb.OpenRecordset("qryFolders", dbOpenSnapshot)
 
Last edited:
There is no space between letters in dbopensnapshot. If you can use the tablename instead.
 

Users who are viewing this thread

Back
Top Bottom