martincabrera33
New member
- Local time
- Yesterday, 21:53
- Joined
- Aug 23, 2020
- Messages
- 8
Hello,
I am new to access, but at work I am trying to speed up a process.
We have an Access DB that has a few forms, in one of them we create new records and for each record we later need to create a folder to contain some documents.
I want to add a button to that form that will create the folder.
The folder has a set input such as "C:\Users\'UserName'\Desktop\etc..." and then some variables that depend on the selected record of the form, for instance the form has a business sector, a date, and a number. I need to create something like:
"C:\Users\'UserName?\Desktop\Business Sector\date(Year)\Number...
I have found many resources but can't manage to understand if I first need to do a query or just with the button and a macro this will work.
On the macro side, I can't get it to look for the info I need, for instance I was trying the following:
Private Sub Crear_Abrir_Carpeta_Click()
MkDir "C:\Users\'UserName'\Desktop\"
Err.Clear
MkDir "C:\Users\'UserName'\Desktop\" & "!Forms!FormName!FieldName"
Err.Clear
MkDir strFolderPath
...
But it is creating me a folder with the actual name of C:\Users\'UserName'\Desktop\!Forms!FormName!FieldName
Not sure how on a Macro to pull the name of the field I need from the record that is currently selected.
Thanks
I am new to access, but at work I am trying to speed up a process.
We have an Access DB that has a few forms, in one of them we create new records and for each record we later need to create a folder to contain some documents.
I want to add a button to that form that will create the folder.
The folder has a set input such as "C:\Users\'UserName'\Desktop\etc..." and then some variables that depend on the selected record of the form, for instance the form has a business sector, a date, and a number. I need to create something like:
"C:\Users\'UserName?\Desktop\Business Sector\date(Year)\Number...
I have found many resources but can't manage to understand if I first need to do a query or just with the button and a macro this will work.
On the macro side, I can't get it to look for the info I need, for instance I was trying the following:
Private Sub Crear_Abrir_Carpeta_Click()
MkDir "C:\Users\'UserName'\Desktop\"
Err.Clear
MkDir "C:\Users\'UserName'\Desktop\" & "!Forms!FormName!FieldName"
Err.Clear
MkDir strFolderPath
...
But it is creating me a folder with the actual name of C:\Users\'UserName'\Desktop\!Forms!FormName!FieldName
Not sure how on a Macro to pull the name of the field I need from the record that is currently selected.
Thanks