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.
Many thanks!Code: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
------------------
Mark Sreeves
Analyst Programmer
[email protected]
A BMW Group Company




Reply With Quote