> If you are using a modern version of Access you could try
>
> StrReverse(Split(StrReverse("Alan Colleyville"), " ")(0))
>
> which returns Colleyville.
Thanks - that code works great for splitting out the Name. But I am having
intermittent problems creating the subdirectory.
Here is a snippet that I found on the Interenet:
Dim fso
Dim fol As String
fol = "c:\MyFolder" ' change to match the folder path
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(fol) Then
fso.CreateFolder (fol)
End If
The line "If Not fso.FolderExists(fol) Then" works with no problem. If I
put a msgbox after this line, I get a message.
But when I use the line "fso.CreateFolder (fol)", I got an error message
the first few times I tried it that the function or command was not found.
Once I tried putting in the Msgbox in place of the CreateFolder command to
test it and after I saw that it worked, I commented that out and then
removed the comment from the CreateFolder command. Now it seems to be
working. Any idea what could cause that anomaly?
Randy Harris - 30 Apr 2006 17:53 GMT
* Colleyville Alan:
>> If you are using a modern version of Access you could try
>>
[quoted text clipped - 24 lines]
> removed the comment from the CreateFolder command. Now it seems to be
> working. Any idea what could cause that anomaly?
Have you tried mkdir?

Signature
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
Lyle Fairfield - 30 Apr 2006 19:28 GMT
>> If you are using a modern version of Access you could try
>>
[quoted text clipped - 4 lines]
> Thanks - that code works great for splitting out the Name. But I am
> having intermittent problems creating the subdirectory.
Sub SaveTheFile(ByVal SomeName As String)
Dim FolderName As String
Dim FolderPath As String
FolderName = StrReverse(Split(StrReverse(SomeName), " ")(0))
FolderPath = "c:\" & FolderName
If Len(Dir$(FolderPath, vbDirectory)) = 0 Then MkDir FolderPath
' more save the file stuff here
End Sub
Sub temp2()
SaveTheFile "Allan Colleyville"
End Sub

Signature
Lyle Fairfield
Colleyville Alan - 30 Apr 2006 22:21 GMT
>>> If you are using a modern version of Access you could try
>>>
[quoted text clipped - 17 lines]
> SaveTheFile "Allan Colleyville"
> End Sub
Thanks