Mark Sreeves
Jan 31st, 2000, 03:34 PM
OK, I need some guidance here.
I wrote a VB frontend to an Access database part of which writes data to files from the database.
I am now trying to put that code into the database itself. Can someone pleas etell me how to change this so it works.
Public Function WriteDIS() As Long
Dim strSQL As String
Dim rstTemp As Recordset
Dim FNum As Integer
On Error GoTo ErrHandler
FNum = FreeFile
'DIS_FILE is a const declared elsewhere
'eg c:\dis.txt
Open DIS_FILE For Output As FNum
'''S10 type
strSQL = "SELECT * FROM tblSupplier;"
Set rstTemp = db.OpenRecordset(strSQL)
While Not rstTemp.EOF
Print #FNum, "S10|" & rstTemp!SupplierCode & "|" & rstTemp!CompanyName
rstTemp.MoveNext
Wend
rstTemp.Close
'''''S3 type
'strSQL = "SELECT tblSupplierTP.SupplierCode, tblSupplierTP.TPCode, tblSupplier.ContactName" & _
'" FROM tblSupplierTP INNER JOIN tblSupplier ON tblSupplierTP.SupplierCode = tblSupplier.SupplierCode;"
'this has been altered to cater for contact names at buisness level
strSQL = "SELECT * FROM tblSupplierTP;"
Set rstTemp = db.OpenRecordset(strSQL)
While Not rstTemp.EOF
Print #FNum, "S3|" & rstTemp!SupplierCode & "DIS" & rstTemp!TpCode & "|" & rstTemp!ContactName
rstTemp.MoveNext
Wend
rstTemp.Close
'''S30 type
strSQL = "SELECT * FROM tblSupplierTP;"
Set rstTemp = db.OpenRecordset(strSQL)
While Not rstTemp.EOF
Print #FNum, "S30|" & rstTemp!SupplierCode & "DIS" & rstTemp!TpCode & "|" & rstTemp!ccode & Trim0(rstTemp!acode) & rstTemp!FaxNo
rstTemp.MoveNext
Wend
rstTemp.Close
WriteDIS = 0
WriteExit:
Close #FNum
Exit Function
ErrHandler:
WriteDIS = Err.Number
GoTo WriteExit
Close #FNum
End Function
Many thanks!
------------------
Mark Sreeves
Analyst Programmer
Mark.Sreeves@Softlab.co.uk
A BMW Group Company
I wrote a VB frontend to an Access database part of which writes data to files from the database.
I am now trying to put that code into the database itself. Can someone pleas etell me how to change this so it works.
Public Function WriteDIS() As Long
Dim strSQL As String
Dim rstTemp As Recordset
Dim FNum As Integer
On Error GoTo ErrHandler
FNum = FreeFile
'DIS_FILE is a const declared elsewhere
'eg c:\dis.txt
Open DIS_FILE For Output As FNum
'''S10 type
strSQL = "SELECT * FROM tblSupplier;"
Set rstTemp = db.OpenRecordset(strSQL)
While Not rstTemp.EOF
Print #FNum, "S10|" & rstTemp!SupplierCode & "|" & rstTemp!CompanyName
rstTemp.MoveNext
Wend
rstTemp.Close
'''''S3 type
'strSQL = "SELECT tblSupplierTP.SupplierCode, tblSupplierTP.TPCode, tblSupplier.ContactName" & _
'" FROM tblSupplierTP INNER JOIN tblSupplier ON tblSupplierTP.SupplierCode = tblSupplier.SupplierCode;"
'this has been altered to cater for contact names at buisness level
strSQL = "SELECT * FROM tblSupplierTP;"
Set rstTemp = db.OpenRecordset(strSQL)
While Not rstTemp.EOF
Print #FNum, "S3|" & rstTemp!SupplierCode & "DIS" & rstTemp!TpCode & "|" & rstTemp!ContactName
rstTemp.MoveNext
Wend
rstTemp.Close
'''S30 type
strSQL = "SELECT * FROM tblSupplierTP;"
Set rstTemp = db.OpenRecordset(strSQL)
While Not rstTemp.EOF
Print #FNum, "S30|" & rstTemp!SupplierCode & "DIS" & rstTemp!TpCode & "|" & rstTemp!ccode & Trim0(rstTemp!acode) & rstTemp!FaxNo
rstTemp.MoveNext
Wend
rstTemp.Close
WriteDIS = 0
WriteExit:
Close #FNum
Exit Function
ErrHandler:
WriteDIS = Err.Number
GoTo WriteExit
Close #FNum
End Function
Many thanks!
------------------
Mark Sreeves
Analyst Programmer
Mark.Sreeves@Softlab.co.uk
A BMW Group Company