I wish to create a file from a record in my table. This is copied to a folder with ftp access where a cohort can get it and update his table.
I guess there's many ways to do this, but with my knowledge I've created the following. (With the help of https://docs.microsoft.com/en-us/office/vba/api/access.docmd.transfertext
tblExport has been copied from tblMain in the GUI, structure only.
The problem is the "Specification name". "Standard Output" does not exist, it was used in the example. The link does sort of explain it,
For a fixed-width text file, you must either specify an argument or use a schema.ini file, which must be stored in the same folder as the imported, linked, or exported text file.
Not sure what I'd want fixed width, wouldn't its current width be better?
Then it goes on
To create a schema file, you can use the text import/export wizard to create the file.
Can someone tell me how to do this, or if I need to (or use am argument(?) instead.
Thanks.
I guess there's many ways to do this, but with my knowledge I've created the following. (With the help of https://docs.microsoft.com/en-us/office/vba/api/access.docmd.transfertext
tblExport has been copied from tblMain in the GUI, structure only.
Code:
Private Sub Command190_Click()
'Copy Record to tblEntry
On Error GoTo err_Bad
Dim r As DAO.Recordset, s As DAO.Recordset
Dim Prefix As String
Dim tr As String
Prefix = Me!lblThisPrefix.Caption
Set r = CurrentDb.OpenRecordset("Select * from tblMain where prefix = '" & Prefix & "';")
'Delete tblExport
DoCmd.SetWarnings False
DoCmd.RunSQL ("Delete * From tblExport")
DoCmd.SetWarnings True
Set s = CurrentDb.OpenRecordset("tblExport")
s.AddNew
For i = 0 To r.Fields.Count - 1
s(i) = r(i)
Next
s.Update
s.Close
r.Close
'transfer the table
tr = BrowseFolder("Destination for " & Prefix)
If FolderExists(tr) = True Then
DoCmd.TransferText acExportDelim, "Standard Output", "tblExport", tr & "\Prefix.doc"
End If
MsgBox "Done"
Leave:
Set s = Nothing
Set r = Nothing
Exit Sub
err_Bad:
MsgBox err.Description
Resume Leave
End Sub
The problem is the "Specification name". "Standard Output" does not exist, it was used in the example. The link does sort of explain it,
For a fixed-width text file, you must either specify an argument or use a schema.ini file, which must be stored in the same folder as the imported, linked, or exported text file.
Not sure what I'd want fixed width, wouldn't its current width be better?
Then it goes on
To create a schema file, you can use the text import/export wizard to create the file.
Can someone tell me how to do this, or if I need to (or use am argument(?) instead.
Thanks.