Create a folder with Date

  • Thread starter Thread starter Lamar
  • Start date Start date
L

Lamar

Hello,

When a user hits a cmd button, I want Access to create a
new folder. I want to name the folder to include date and
time the end

i.e. Name the folder: SeaRob526041130 with 52604
meaning 5/26/04 and 1130 meaning 11:30

I know how create new folder but can not add the date and
time. Is this even possible? See VBA code below. Thanks
for any help.

MkDir "C:\HousAuth\" & Left(cmbHA, 3) & Left(cmbESDStaff,
3)
 
Lamar said:
Hello,

When a user hits a cmd button, I want Access to create a
new folder. I want to name the folder to include date and
time the end

i.e. Name the folder: SeaRob526041130 with 52604
meaning 5/26/04 and 1130 meaning 11:30

I know how create new folder but can not add the date and
time. Is this even possible? See VBA code below. Thanks
for any help.

MkDir "C:\HousAuth\" & Left(cmbHA, 3) & Left(cmbESDStaff,
3)

Use the Format function. e.g.

Format(Now, "mdyyhhnn")
 
Assuming that you want the current date and time:

Dim datDateTime As Date
varDateTime = Now()
MkDir "C:\HousAuth\" & Left(cmbHA, 3) & Left(cmbESDStaff, 3) &
Format(varDateTime, "mmddyy") & Format(varDateTime ,"hhnn")
 
Back
Top