By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,087 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

Verifying folder name

P: n/a
I have inherited a small DB in my office and was wondering if someone could
provide some advice. Currently the DB allows the office manager to archive
the data for each year under the DB's program folder. These folders are named
after the year eg 2005, 2006, 2007 etc, and these folders do not contain any
text in their name.

The DB uses the following code to check that the selected folder is actually
under the program's folder:

************
ProgramPath = [Application].[CurrentProject].[Path]

ArchiveFolder = BrowseForFolderByPath(ProgramPath)

'check if user has clicked the Cancel button.
If ArchiveFolder = vbNullString Then

Exit Sub

End If

'check if the selected folder is under the program folder.
If Left(ArchiveFolder, Len(ArchiveFolder) - 5) <ProgramPath Then

MsgBox "That is an invalid Archive folder." & Chr$(13) & Chr$(13)
& _
"Archives are located in the " & ProgramPath & " folder." & Chr$
(13) & Chr$(13) & _
"Please select an archive in the " & ProgramPath & " folder.",
vbOKOnly +
vbInformation, "Invalid Archive Folder."

Exit Sub

End If

**************

Some of the office staff are selecting the wrong folder under the program
folder. I would like to know how to code the situation where if a user
selects a subfolder under the program folder that is not 2005, 2006 or 2007
etc then the application says "Invalid Folder" when they click OK on the
Browse for Folder dialog box. In other words, I would only like to have them
select the folders that contain only numbers in their name.

Is this possible?

Many thanks,
Anthony

--
Message posted via http://www.accessmonster.com

May 17 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Anthony.

I noticed you solved this with:
<snip>
(Right(ArchiveFolder, 4)) Like "*[!0-9]*" Then

Here's a quick experiment from my DeBug window (Access 97)
? IsNumeric("2005")
True

? IsNumeric("2005a")
False

'Nuff said?

Cheers,
Alan
May 22 '07 #2

P: n/a
Hi Alan,

Thank you. Sometimes we miss the bleeding obvious!

Regards
Anthony

Alan Carpenter wrote:
>Hi Anthony.

I noticed you solved this with:
<snip>
(Right(ArchiveFolder, 4)) Like "*[!0-9]*" Then

Here's a quick experiment from my DeBug window (Access 97)

? IsNumeric("2005")
True

? IsNumeric("2005a")
False

'Nuff said?

Cheers,
Alan
--
Message posted via http://www.accessmonster.com

May 22 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.