Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 3rd, 2007, 08:42 AM
Authorized User
 
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Accessing Network Share with Access VBA

        '***make directory TEMP
        Dim newFOL As String

        newFOL = txtHrmRef & " - " & txtName & " - " & txtBenCode
        ChDir "\\resrslavingt002\u_datacentre"

        MkDir (newFOL)

Hi, using this as my code, for somereason it goes ok with no error messages but doesnt create a folder, confused! it works fine if i set the path to the C:\xxx\xxx but using the network name no joy, i have full rights to the drive.

Cheers

 
Old January 3rd, 2007, 01:39 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You can do this:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder("Z:\MyFolder")

See if you can use that code. I am not sure it it uses UNC naming.



mmcdonal
 
Old January 3rd, 2007, 02:13 PM
Authorized User
 
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok that works thank you very much! my question now is using FSO how can i incorporate my newFol string?
Many thanks

 
Old January 3rd, 2007, 02:58 PM
Authorized User
 
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Hi,
My end goal is to create a new folder with a name based on 3 txt box elements from my form,
then 2 folders get copied into that folder.

So far i can create a folder (i put a dummy name in the code) & i can copy in the folders and files.
there are 2 issues.

firstly although the folders and contents copy fine i get a error "type mismatch" the [on error resume next] gets rid of that but im curious to know why it is so.

Secondly how can i make it so that the folder is named from my string?
i know its something simple but i dont know much about this stuff - im learning as i go along!

    Private Sub cmdMkDir_Click()
    Dim newFOL As String

    newFOL = "\\resrslavingt002\u_datacentre\MM" & " \ " & txtHrmRef & " - " & txtName & " - " & txtBenCode
    On Error Resume Next

    Set objFSO = CreateObject("scripting.filesystemobject")
    Set objFolder = objFSO.CreateFolder("\\resrslavingt002\u_datacentr e\HRM\Projects\Existing Projects\0TEST0")
    Set objCopyFolder = objFSO.copyfolder("\\resrslavingt002\u_datacentre\ HRM\Projects\New Project Templates\NEW HRM TEAM JOB AID\*", "\\resrslavingt002\u_datacentre\HRM\Projects\Exist ing Projects\0TEST0\", False)

End SubThanks



 
Old January 3rd, 2007, 03:03 PM
Authorized User
 
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Amended

Private Sub cmdMkDir_Click()
    Dim newFOL As String

    newFOL = "\\resrslavingt002\u_datacentre\MM" & " \ " & txtHrmRef & " - " & txtName & " - " & txtBenCode
    'On Error Resume Next

    Set objFSO = CreateObject("scripting.filesystemobject")
    Set objFolder = objFSO.CreateFolder("\\resrslavingt002\u_datacentr e\HRM\Projects\Existing Projects\0TEST0\")
    Set objCopyFolder = objFSO.copyfolder("\\resrslavingt002\u_datacentre\ HRM\Projects\New Project Templates\NEW HRM TEAM JOB AID\*", objFolder, False)

End Sub

 
Old January 3rd, 2007, 03:11 PM
Authorized User
 
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok fixed it i was messing around with the string earlier and put in "\\resrslavingt002\u_datacentre\MM" & " took it out and of course it works fine now DUH.
Cheers again

 
Old January 3rd, 2007, 03:43 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

So you don't need any more help with this? I was at meetings most of the day so couldn't reply.

mmcdonal
 
Old January 4th, 2007, 08:17 AM
Authorized User
 
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Am still wondering about the type mismatch error?
it works fine with "on error resume next" but if it can be fixed rather than hidden!
Cheers


 
Old January 4th, 2007, 08:23 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Are you declaring the objFSO etc as Variants?

mmcdonal
 
Old January 4th, 2007, 11:11 AM
Authorized User
 
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

do you mean
    Dim objFSO As Variant
    Dim objFolder As Variant
    Dim objCopyFolder As Variant

sorry im new to this! but no that doesnt make a difference, the error is in the objcopyfolder line






Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating folders on network share JonniP Access VBA 1 January 3rd, 2007 03:51 PM
running ROBOCOPY on network share? froztbyte Classic ASP Professional 0 September 28th, 2006 08:26 PM
Accessing 2 Access Databases using VBA mays0515 Access VBA 3 August 4th, 2005 12:58 PM
Use VBA to get data from Access (Share folder) ckentebe Access 6 April 28th, 2004 10:09 PM
Use VBA to get data from Access (Share folder) ckentebe Access 1 April 21st, 2004 06:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.