Hello everyone,
I'm trying to create an attachment buttom to a predefined directory location (location would be based on the name of my field "Code_Id")
First of all, I received the help to create a buttom that creates an specific folder named as my field "Code_Id"
************************************************** ***************
https://www.accessforums.net/access/...tml#post302809
Private Sub Createcmd_Click()
Dim startPath As String
Dim finalPath As String
' Enter starting path prefix
startPath = "C:\Users\General\Desktop"
' Check to see if Code_Id entered
If IsNull(Me.Code_Id) Then
MsgBox "No Code ID entered"
Else
' Build final path string
finalPath = TrailingSlash(startPath) & Me.Code_Id
' Check to see if folder already exists
If FolderExists(finalPath) Then
MsgBox "The following path already exists:" & vbCrLf & finalPath
Else
' If not, create it
On Error GoTo err_check
MkDir finalPath
MsgBox "Successfully created folder: " & vbCrLf & finalPath
On Error GoTo 0
End If
End If
Exit Sub
' Error message to return if folder name is not valid err_check:
Do you happen to know, the next.... based on the same of course...
I would like to add some files to this pre-defined location (new folder created)
I meant:
1. Create a buttom named "Addfilescmd"
2. Define an Event Addfilescmd_Onclick
3. Open any directory (I have the code to do this "EscogeFichero"
4 Instead (on my code) just to copy the root directory, I would like to copy the file and locate this one into the new location created
Please see the code:
Module "EscogeFichero"
************************************************** ******************************
Option Compare Database
Option Explicit
Function EscogeFichero(Tipo As Integer) As String
'Variables'
Dim wzhwndOwner As Long
Dim wzAppName As String
Dim wzDlgTitle As String
Dim wzOpenTitle As String
Dim wzFile As String
Dim wzInitialDir As String
Dim wzFilter As String
Dim wzFilterIndex As Long
Dim wzView As Long
Dim wzflags As Long
Dim wzfOpen As Boolean
Dim Ret As Long
'On Error go to'
On Error GoTo EscogeFichero_Err
WizHook.Key = 51488399
wzhwndOwner = 0&
wzAppName = ""
If Tipo = 1 Then
wzDlgTitle = "Escoge fichero para guardar"
Else
wzDlgTitle = "Escoja fichero gráfico (Jpj,Gif etc) como fondo del Email"
End If
wzOpenTitle = "Escoja fichero"
wzFile = String(255, Chr(0))
wzInitialDir = CurrentProject.Path & "\"
If Tipo = 1 Then
wzFilter = "Cualquier fichero " _
& "(*.*)"
Else
wzFilter = "Fichero Gráfico " _
& "(*.jpg;*.gif;*.bmp)"
End If
wzFilterIndex = 1
wzView = 1
wzflags = 64
wzfOpen = True
Ret = WizHook.GetFileName(wzhwndOwner, _
wzAppName, wzDlgTitle, wzOpenTitle, wzFile, _
wzInitialDir, wzFilter, wzFilterIndex, _
wzView, wzflags, wzfOpen)
If Ret <> -302 Then
EscogeFichero = wzFile
Else
EscogeFichero = ""
End If
EscogeFichero_Exit:
Exit Function
EscogeFichero_Err:
MsgBox "Error nº " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
"en procedimiento EscogeFichero de Módulo EscogeFichero", vbCritical, "Aviso de error"
Resume EscogeFichero_Exit
End Function
************************************************** ****************************
And into the form a buttom named "Problemsupportcmd"
Me.Problemsupporttxt = EscogeFichero(1) '1 es para cualquier tipo de ficheros
CmdOpen_Click_Exit:
Exit Sub
CmdOpen_Click_Err:
MsgBox "Error nº " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
"en procedimiento CmdOpen_Click de Documento VBA Form_FrmMensaje", vbCritical, "Aviso de error"
Resume CmdOpen_Click_Exit
************************************************** **********************
Basically I want to create the attachment option but the directory will be related to new folder named as my field "Code_Id" located at the same form
Thanks!!!!![]()