Results 1 to 8 of 8

Thread: [RESOLVED] How do I export a to a text file not using TransferText

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    6

    Resolved [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.

  2. #2
    Hyperactive Member
    Join Date
    Jul 2005
    Location
    South Africa
    Posts
    400

    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:
    1. Private Sub Command1_Click()
    2.     Dim ff As Integer
    3.         ff = FreeFile()
    4.             Open ("C:\test.txt") For Append As ff
    5.                 Print #ff, 'Your recordset'
    6.                 Close
    7. 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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    6

    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:
    1. Private Sub Command1_Click()
    2.     Dim ff As Integer
    3.         ff = FreeFile()
    4.             Open ("C:\test.txt") For Append As ff
    5.                 Print #ff, 'Your recordset'
    6.                 Close
    7. 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

  4. #4
    Hyperactive Member
    Join Date
    Jul 2005
    Location
    South Africa
    Posts
    400

    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

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    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
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How do I export a to a text file not using TransferText

    Moved
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    New Member
    Join Date
    Apr 2009
    Posts
    1

    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

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width