auto numbering

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
 
P

Patrick Molloy

use the CHDRIVE and CHDIR to repoint the system,

Const sDEFAULT_PATH As String = "C:\seqnum"
Const sDEFAULT_FNAME As String = "DefaultSeqInv.txt"
Dim nFileNumberInv As Long
CHDRIVE LEFT(sDEFAULT_PATH,2)
CHDIR sDEFAULT_PATH
 
O

Oakleaf tech

That did the job

THx a million!!!

Patrick Molloy said:
use the CHDRIVE and CHDIR to repoint the system,

Const sDEFAULT_PATH As String = "C:\seqnum"
Const sDEFAULT_FNAME As String = "DefaultSeqInv.txt"
Dim nFileNumberInv As Long
CHDRIVE LEFT(sDEFAULT_PATH,2)
CHDIR sDEFAULT_PATH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top