O
Oakleaf tech
I am using a function that does autonumbering for a invoice using a *.txt file.
My problem is although i have spesified a default path for the txt file it
still safes it in the "my documents" folder and not the default path as
spesified in the code. I am using vista business and office 2007 pro.
here is the code
Public Function NextSeqNumberInv(Optional sFileNameInv As String, Optional
nSeqNumberInv As Long = -1) As Long
'invoice autonumbering
Const sDEFAULT_PATH As String = "C:\seqnum"
Const sDEFAULT_FNAME As String = "DefaultSeqInv.txt"
Dim nFileNumberInv As Long
nFileNumberInv = FreeFile
If sFileNameInv = "" Then sFileNameInv = sDEFAULT_FNAME
If InStr(sFileNameInv, Application.PathSeparator) = 0 Then _
sFileName = sDEFAULT_PATH & Application.PathSeparator &
sFileNameInv
If nSeqNumberInv = -1& Then
If Dir(sFileNameInv) <> "" Then
Open sFileNameInv For Input As nFileNumberInv
Input #nFileNumberInv, nSeqNumberInv
nSeqNumberInv = nSeqNumberInv + 1&
Close nFileNumberInv
Else
nSeqNumberInv = 1&
End If
End If
On Error GoTo PathError
Open sFileNameInv For Output As nFileNumberInv
On Error GoTo 0
Print #nFileNumberInv, nSeqNumberInv
Close nFileNumberInv
NextSeqNumberInv = nSeqNumberInv
Exit Function
PathError:
NextSeqNumberInv = -1&
End Function
Pls help I don't know where am i goign wrong with this
My problem is although i have spesified a default path for the txt file it
still safes it in the "my documents" folder and not the default path as
spesified in the code. I am using vista business and office 2007 pro.
here is the code
Public Function NextSeqNumberInv(Optional sFileNameInv As String, Optional
nSeqNumberInv As Long = -1) As Long
'invoice autonumbering
Const sDEFAULT_PATH As String = "C:\seqnum"
Const sDEFAULT_FNAME As String = "DefaultSeqInv.txt"
Dim nFileNumberInv As Long
nFileNumberInv = FreeFile
If sFileNameInv = "" Then sFileNameInv = sDEFAULT_FNAME
If InStr(sFileNameInv, Application.PathSeparator) = 0 Then _
sFileName = sDEFAULT_PATH & Application.PathSeparator &
sFileNameInv
If nSeqNumberInv = -1& Then
If Dir(sFileNameInv) <> "" Then
Open sFileNameInv For Input As nFileNumberInv
Input #nFileNumberInv, nSeqNumberInv
nSeqNumberInv = nSeqNumberInv + 1&
Close nFileNumberInv
Else
nSeqNumberInv = 1&
End If
End If
On Error GoTo PathError
Open sFileNameInv For Output As nFileNumberInv
On Error GoTo 0
Print #nFileNumberInv, nSeqNumberInv
Close nFileNumberInv
NextSeqNumberInv = nSeqNumberInv
Exit Function
PathError:
NextSeqNumberInv = -1&
End Function
Pls help I don't know where am i goign wrong with this