Help to create folder in location

alvarogueva

Registered User.
Local time
Today, 05:56
Joined
Nov 5, 2016
Messages
91
Well;

Hello there.

I have someone who code me once a button to create a Folder in a specific location.

This is the Code:

"Private Sub BtnCreateCustomerFolder_Click()
Dim strtemp As String
Dim strPathPrefix As String
Dim strPathSuffix As String
strPathPrefix = "\\*******\Database\Customers\"
strPathSuffix = "\Docs\"
If Me.CustomerName.Value & "" = "" And Me.CustomerLastName.Value & "" = "" Then
MsgBox "Customer Name must be filled in first"
Else
strtemp = strPathPrefix & Replace((Me.CustomerName.Value & ""), "'", "") & Replace((Me.CustomerLastName.Value & ""), "'", "")
If Len(Dir(strtemp, vbDirectory)) = 0 Then
MkDir strtemp
End If
strtemp = strtemp & strPathSuffix
If Len(Dir(strtemp, vbDirectory)) = 0 Then
MkDir strtemp
End If
Shell "C:\WINDOWS\explorer.exe """ & strtemp & "", vbNormalFocus
End If
End Sub"


Does anyone know if I need to create a new one, or just add in here more stuff??

Thanks!
 
I would be inclined to do something like below. You can control the path from each button that calls the routine. You can do this without fiddling around with the routine itself. if you were going to use the same routine, but with a different form, then you should think about moving the reference to the text boxes to the routine parameter stub as well.. Note The function shown will also work as a Subroutine.

Code:
Private Sub BtnCreateCustomerFolder_Click()
Dim strPathPrefix As String
Dim strPathSuffix As String

strPathPrefix = "C:\ATH_PC_Drive_W8\Google Drive\ATH_Drive\ATH_Business\ATH_Products\Create A Folder\Customer_"
strPathSuffix = "Sufix"

    Call fCreateFolder(strPathPrefix, strPathSuffix)

End Sub


Private Function fCreateFolder(strPathPrefix As String, strPathSuffix As String)
'Help to create folder in location
'http://www.access-programmers.co.uk/forums/showthread.php?t=290327

Dim strTemp As String
    
    If Me.txtCustomerName.Value & "" = "" And Me.txtCustomerLastName.Value & "" = "" Then
        
        MsgBox "Customer Name must be filled in first"
    
    Else    'Replace removes any apostrophe's
        strTemp = strPathPrefix & Replace((Me.txtCustomerName.Value & ""), "'", "") & Replace((Me.txtCustomerLastName.Value & ""), "'", "")
    
                If Len(Dir(strTemp, vbDirectory)) = 0 Then
                    MkDir strTemp
                End If
        
                        strTemp = strTemp & strPathSuffix
                
                If Len(Dir(strTemp, vbDirectory)) = 0 Then
                    MkDir strTemp
                End If
    
        'Open the Newly Created Folder
        Shell "C:\WINDOWS\explorer.exe """ & strTemp & "", vbNormalFocus
    
    End If

End Function      'fCreateFolder
 
Last edited:
I would be inclined to do something like below. You can control the path from each button that calls the routine. You can do this without fiddling around with the routine itself. if you were going to use the same routine, but with a different form, then you should think about moving the reference to the text boxes to the routine parameter stub as well.. Note The function shown will also work as a Subroutine.

Code:
Private Sub BtnCreateCustomerFolder_Click()
Dim strPathPrefix As String
Dim strPathSuffix As String

strPathPrefix = "C:\ATH_PC_Drive_W8\Google Drive\ATH_Drive\ATH_Business\ATH_Products\Create A Folder\Customer_"
strPathSuffix = "Sufix"

    Call fCreateFolder(strPathPrefix, strPathSuffix)

End Sub


Private Function fCreateFolder(strPathPrefix As String, strPathSuffix As String)
'Help to create folder in location
'http://www.access-programmers.co.uk/forums/showthread.php?t=290327

Dim strTemp As String
    
    If Me.txtCustomerName.Value & "" = "" And Me.txtCustomerLastName.Value & "" = "" Then
        
        MsgBox "Customer Name must be filled in first"
    
    Else    'Replace removes any apostrophe's
        strTemp = strPathPrefix & Replace((Me.txtCustomerName.Value & ""), "'", "") & Replace((Me.txtCustomerLastName.Value & ""), "'", "")
    
                If Len(Dir(strTemp, vbDirectory)) = 0 Then
                    MkDir strTemp
                End If
        
                        strTemp = strTemp & strPathSuffix
                
                If Len(Dir(strTemp, vbDirectory)) = 0 Then
                    MkDir strTemp
                End If
    
        'Open the Newly Created Folder
        Shell "C:\WINDOWS\explorer.exe """ & strTemp & "", vbNormalFocus
    
    End If

End Function      'fCreateFolder

I'm sorry. I lost you half way... Could you explain it to me with more detail? Also, I am going to follow your VBA study guide lol :)
 
I'm sorry. I lost you half way... Could you explain it to me with more detail?

There's not a lot to explain so I'm a bit confused by your request.

Have you tried the code in your database?

If you have and it didn't work what error message did you get?

I can see that I prefixed some of the text box names with "txt" so you need to either remove this (I don't recommend that) or change your text boxes so the names are the same as in the code.



Sent from my SM-G925F using Tapatalk
 
Well;

Hello there. I am still unable to fix this code:

Code:
Private Sub BtnCreateCompanyFolder_Click()
Dim strtemp As String
Dim strPathPrefix As String
Dim strPathSuffix As String
strPathPrefix = "\\4GLOBALCORP-PC\Database\Customers\"  <---- [COLOR="Red"]Can't create the folder to go into the actual customer Folder Name. It is supose to go into each customer ( who is selected in the Nav bar, and place the folder in this customer Folder.[/COLOR]
strPathSuffix = "\Company\"
If Me.CompanyName.Value & "" = "" Then
    MsgBox "Company Name must be filled in first"
Else
    strtemp = strPathPrefix & Replace((Me.CompanyName.Value & ""), "'", "")
    If Len(Dir(strtemp, vbDirectory)) = 0 Then
        MkDir strtemp
    End If
    strtemp = strtemp & strPathSuffix
    If Len(Dir(strtemp, vbDirectory)) = 0 Then
        MkDir strtemp
    End If
    Shell "C:\WINDOWS\explorer.exe """ & strtemp & "", vbNormalFocus
End If
End Sub


An example of this should be as follows:
\\4GLOBALCORP-PC\Database\Customers\Frank Perez\ <---- This is the part that IDK HOW TO DO!!!!!


If anyone has an idea that I can implement. Let me know. :)

Thank you guys!!!!
 
<---- This is the part that IDK HOW TO DO!!!!!

I assume you meant to say:-
- This is the part that I don't know HOW TO DO!!!!

The code works fine on my PC.

Sent from my SM-G925F using Tapatalk
 
I assume you meant to say:-
- This is the part that I don't know HOW TO DO!!!!

The code works fine on my PC.

Sent from my SM-G925F using Tapatalk

is it creating a folder inside of the customer folder???

cause mine is creating it but in the same folder as where all the customer folders are...
 
I think the problem is it's not clear what you want. I suggest you show some example URL's based on the following names:-
Julian Assange
Donald Trump
Fred West
Angela Merkel
Theresa May
Bob the Builder
 
I think the problem is it's not clear what you want. I suggest you show some example URL's based on the following names:-
Julian Assange
Donald Trump
Fred West
Angela Merkel
Theresa May
Bob the Builder

well, the path would be:

strPathPrefix = "\\4GLOBALCORP-PC\Database\Customers\Julian Assange
strPathPrefix = "\\4GLOBALCORP-PC\Database\Customers\Donald Trump
strPathPrefix = "\\4GLOBALCORP-PC\Database\Customers\Fred West

etc....

What I need is to create a new folder inside the folder that this code creates. the code creates a folder names Docs inside each customer.
 
Please show the full path it should look something like this:-

Code:
strPathPrefix = "C:\ABC_W4\Google Drive\4GLOBALCORP-PC\Database\Customers\Donal Trump\"

In other words it must start with a drive letter C:, D:, X:... etc
 
To avoid any confusion please show the URL with the actual suffix in exactly the way that you want it to appear. The way you have shown it, it is subject to different interpretations. There's no point in me assuming one or the other. It's would be far better you demonstrate exactly what you want.
 
To avoid any confusion please show the URL with the actual suffix in exactly the way that you want it to appear. The way you have shown it, it is subject to different interpretations. There's no point in me assuming one or the other. It's would be far better you demonstrate exactly what you want.

I am sorry but I am confused....
 
What is the purpose of the suffix? What functionality does it give you? For example, if its purpose is to add a folder give the URL of the folder you would expect to see, related to the examples I have already suggested. If you expect the suffix to be concatenated to the end of the first name last name then show a URL in that format.
 
By the way if you are worried (quite rightly) about revealing sensitive company information or personal information in the URL's you post, then modify the URL by replacing this sensitive information with "SECRET" or some other word(s) which don't reveal anything sensitive.
 
By the way if you are worried (quite rightly) about revealing sensitive company information or personal information in the URL's you post, then modify the URL by replacing this sensitive information with "SECRET" or some other word(s) which don't reveal anything sensitive.


Just did that, here is the database clean and working, to see if maybe we can fix this :)
 

Attachments

I'm not able to get to a PC at the moment, so I suggest you post the UNC URL I mentioned earlier. Otherwise you will need to wait a few days, unless someone else picks up the baton.

Sent from my SM-G925F using Tapatalk
 
I'm not able to get to a PC at the moment, so I suggest you post the UNC URL I mentioned earlier. Otherwise you will need to wait a few days, unless someone else picks up the baton.

Sent from my SM-G925F using Tapatalk

how do i do that???
 
Further to PMs, I looked at your database. I don't see where you have attempted to use zip codes/google maps.
What exactly are you wanting to do?
Where are you specs/requirements?
Where are your efforts so far?
 

Users who are viewing this thread

Back
Top Bottom