In inStr function and using it has always caused me a headache.
I did the following to get the [personName] from the datafile path. I would
like to know if there was an easier way to accomplish the same.
------------------------------------------------------------
'Get the Person name from the file path
'example C:\ProjectName_ContractCode_\DatabaseName_PersonName.mdb
Dim CPos, LastPos, DPos, UPos, nameLength As Integer
'Get the position of the .dot
DPos = InStr(strPath, ".")
'There are several underscores in the path
'I know the name comes after the last underscore
'Get the position of the last underscore
CPos = InStr(strPath, "_")
Do While CPos > 0
LastPos = CPos
CPos = InStr(CPos + 1, strPath, "_")
Loop
'the length of the name is the distance between the last underscore and the
dot
nameLength = DPos - LastPos - 1
strName = Right$(strPath, (nameLength + 4))
strName = Left$(strName, nameLength)
Ken Snell (MVP) - 14 Nov 2007 21:24 GMT
Perhaps this will be easier, based on the example that has underscore before
person's name:
Left(Mid(strPath, InStrRev(strPath, "_") + 1), Len(Mid(strPath,
InStrRev(strPath, "_") + 1)) - 4)

Signature
Ken Snell
<MS ACCESS MVP>
> In inStr function and using it has always caused me a headache.
>
[quoted text clipped - 27 lines]
> strName = Right$(strPath, (nameLength + 4))
> strName = Left$(strName, nameLength)
Lisab - 14 Nov 2007 23:46 GMT
THANKS.
OMG, I have to be fresh and headach free in order to deal with mixing the
Left,Right, Mid, & InStr functions :)
InStrRev --> that a new one I didn't know about
Thanks again.
> Perhaps this will be easier, based on the example that has underscore before
> person's name:
[quoted text clipped - 33 lines]
> > strName = Right$(strPath, (nameLength + 4))
> > strName = Left$(strName, nameLength)