Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 3rd, 2007, 07:42 AM
Authorized User
 
Join Date: Jan 2007
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old January 3rd, 2007, 12:39 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 62%
Activity: 62% Activity: 62% Activity: 62%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #3 (permalink)  
Old January 3rd, 2007, 01:13 PM
Authorized User
 
Join Date: Jan 2007
Location: , , .
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

Reply With Quote
  #4 (permalink)  
Old January 3rd, 2007, 01:58 PM
Authorized User
 
Join Date: Jan 2007
Location: , , .
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



Reply With Quote
  #5 (permalink)  
Old January 3rd, 2007, 02:03 PM
Authorized User
 
Join Date: Jan 2007
Location: , , .
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

Reply With Quote
  #6 (permalink)  
Old January 3rd, 2007, 02:11 PM
Authorized User
 
Join Date: Jan 2007
Location: , , .
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

Reply With Quote
  #7 (permalink)  
Old January 3rd, 2007, 02:43 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 62%
Activity: 62% Activity: 62% Activity: 62%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #8 (permalink)  
Old January 4th, 2007, 07:17 AM
Authorized User
 
Join Date: Jan 2007
Location: , , .
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


Reply With Quote
  #9 (permalink)  
Old January 4th, 2007, 07:23 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 62%
Activity: 62% Activity: 62% Activity: 62%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Are you declaring the objFSO etc as Variants?

mmcdonal
Reply With Quote
  #10 (permalink)  
Old January 4th, 2007, 10:11 AM
Authorized User
 
Join Date: Jan 2007
Location: , , .
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

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating folders on network share JonniP Access VBA 1 January 3rd, 2007 02: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



All times are GMT -4. The time now is 04:20 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.