Hi,
I have a function already setup the creates a text file of orders. I need a function that copies this file to a particluar location on our server if it doesn't already exist, and if it does, then it appends to the existing file.
Will this be hard to do? I can use a form to do this, I just am not familiar with the coding required. The function I use to create the text file is below if you need it.
Thanks so much in advance.
TN
-------------------------
strSql = "SELECT * FROM TBLHEADERS WHERE UPLOADED = FALSE ORDER BY DeliveryDate"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSql, dbOpenDynaset)
rs.MoveFirst
Set fs = CreateObject("Scripting.FileSystemObject"
Set f = fs.OpenTextFile(strTextName, ForWriting, 0)
While Not rs.EOF
strBuffer = rs!Imported
Mid(strBuffer, 1, 1) = "0"
strValue = Format(Str(rs!RouteNbr), "0000"
Mid(strBuffer, 2, 4) = strValue
strValue = Format(Str(rs!CustomerNbr), "000000000"
Mid(strBuffer, 6, 9) = strValue
strValue = Format(rs!DeliveryDate, "mmddyyyy"
Mid(strBuffer, 15, 8) = strValue
strValue = Format(Str(rs!TotQuantity), "000000000"
Mid(strBuffer, 23, 9) = strValue
f.WriteLine (strBuffer)
strSql2 = "SELECT * FROM tblOrders WHERE UPLOADED = FALSE AND FKPKEY = " _
& rs!pkey
rs.Edit
rs!Uploaded = True
rs.Update
Set rs1 = db.OpenRecordset(strSql2, dbOpenDynaset)
If rs1.RecordCount > 0 Then
rs1.MoveFirst
While Not rs1.EOF
strBuffer = rs1!Imported
Mid(strBuffer, 1, 1) = "1"
strValue = Format(Str(rs1!ProductNbr), "000000000"
Mid(strBuffer, 2, 9) = strValue
strValue = Format(Str(rs1!Quantity), "000000"
Mid(strBuffer, 18, 6) = strValue
f.WriteLine (strBuffer)
rs1.Edit
rs1!Uploaded = True
rs1.Update
rs1.MoveNext
Wend
rs1.Close
End If
rs.MoveNext
Wend
GoTo ExitUpload
I have a function already setup the creates a text file of orders. I need a function that copies this file to a particluar location on our server if it doesn't already exist, and if it does, then it appends to the existing file.
Will this be hard to do? I can use a form to do this, I just am not familiar with the coding required. The function I use to create the text file is below if you need it.
Thanks so much in advance.
TN
-------------------------
strSql = "SELECT * FROM TBLHEADERS WHERE UPLOADED = FALSE ORDER BY DeliveryDate"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSql, dbOpenDynaset)
rs.MoveFirst
Set fs = CreateObject("Scripting.FileSystemObject"
Set f = fs.OpenTextFile(strTextName, ForWriting, 0)
While Not rs.EOF
strBuffer = rs!Imported
Mid(strBuffer, 1, 1) = "0"
strValue = Format(Str(rs!RouteNbr), "0000"
Mid(strBuffer, 2, 4) = strValue
strValue = Format(Str(rs!CustomerNbr), "000000000"
Mid(strBuffer, 6, 9) = strValue
strValue = Format(rs!DeliveryDate, "mmddyyyy"
Mid(strBuffer, 15, 8) = strValue
strValue = Format(Str(rs!TotQuantity), "000000000"
Mid(strBuffer, 23, 9) = strValue
f.WriteLine (strBuffer)
strSql2 = "SELECT * FROM tblOrders WHERE UPLOADED = FALSE AND FKPKEY = " _
& rs!pkey
rs.Edit
rs!Uploaded = True
rs.Update
Set rs1 = db.OpenRecordset(strSql2, dbOpenDynaset)
If rs1.RecordCount > 0 Then
rs1.MoveFirst
While Not rs1.EOF
strBuffer = rs1!Imported
Mid(strBuffer, 1, 1) = "1"
strValue = Format(Str(rs1!ProductNbr), "000000000"
Mid(strBuffer, 2, 9) = strValue
strValue = Format(Str(rs1!Quantity), "000000"
Mid(strBuffer, 18, 6) = strValue
f.WriteLine (strBuffer)
rs1.Edit
rs1!Uploaded = True
rs1.Update
rs1.MoveNext
Wend
rs1.Close
End If
rs.MoveNext
Wend
GoTo ExitUpload