[RESOLVED] How do I export a to a text file not using TransferText
Hi Guys
I am using VBA.
I have created a form with a subform in it and they are both liked with a suplier number.
My problem is that I want to export to a text file using a botton. I want the information on the text file in this format.
The first line to be suplier number from the parent table. The second line to be the invoices from the child table which is my subform.
I have tried using the write and TransfareText method but have not succeded if you have any idea please assist.
Thanx a million. :wave:
Re: How do I export a to a text file not using TransferText
Hi there
To write to a text file try something like this.
VB Code:
Private Sub Command1_Click()
Dim ff As Integer
ff = FreeFile()
Open ("C:\test.txt") For Append As ff
Print #ff, 'Your recordset'
Close
End Sub
Hope this sets you on the right path. If you need more help let me know as i have done this quite a bit lately.
Re: How do I export a to a text file not using TransferText
Quote:
Originally Posted by alexanderjames
Hi there
To write to a text file try something like this.
VB Code:
Private Sub Command1_Click()
Dim ff As Integer
ff = FreeFile()
Open ("C:\test.txt") For Append As ff
Print #ff, 'Your recordset'
Close
End Sub
Hope this sets you on the right path. If you need more help let me know as i have done this quite a bit lately.
Thank you sir
I have tried that method and it worked fine with the parent form, but accessing the information on the subform is the problem now.
How can I seach the child table from the form and print the result on the to the same text file.
Regards
Re: How do I export a to a text file not using TransferText
Hi there
If you could post your code, then i am sure i could help you out.
Regards
Re: How do I export a to a text file not using TransferText
The syntax for obtaining data on the child form when in the parent form is:
childformname.datathing
Re: How do I export a to a text file not using TransferText
Re: How do I export a to a text file not using TransferText
Hi
I've tried using the transfertext method, with no success. Keep getting error 424: object not defined.
You mention another way. This creates the text file, but doesnt put anything in it. What I'm looking for is a way to export all the records of an access table to a text file. I would have thought this would have been easier than it is!!
Can anyone help?
Thanks
Re: How do I export a to a text file not using TransferText
you have to put what you want to print to the file in the line
print #ff, "test to print to file"
you can print any string or content of variable,or recordset, into the file
btw, better to start your own thread