 |
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
|
|
|

January 3rd, 2007, 08:42 AM
|
Authorized User
|
|
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

January 3rd, 2007, 01:39 PM
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
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
|

January 3rd, 2007, 02:13 PM
|
Authorized User
|
|
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ok that works thank you very much! my question now is using FSO how can i incorporate my newFol string?
Many thanks
|

January 3rd, 2007, 02:58 PM
|
Authorized User
|
|
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

January 3rd, 2007, 03:03 PM
|
Authorized User
|
|
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

January 3rd, 2007, 03:11 PM
|
Authorized User
|
|
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

January 3rd, 2007, 03:43 PM
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
So you don't need any more help with this? I was at meetings most of the day so couldn't reply.
mmcdonal
|

January 4th, 2007, 08:17 AM
|
Authorized User
|
|
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

January 4th, 2007, 08:23 AM
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Are you declaring the objFSO etc as Variants?
mmcdonal
|

January 4th, 2007, 11:11 AM
|
Authorized User
|
|
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |