L
Lisab
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)
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)