Results 1 to 4 of 4
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Share a txt file between parent and child


    A text log file is open in the parent as #1. Clearly
    Code:
    me.Parent.print #1, " testing"
    doesn't work. I can envision closing #1 in the parent, opening the file for append in the child and closing it again when the child has finished its tasks. Then, finally, re-opening the file for append in the parent.

    The question becomes is there a easier/better way to share the log file?

  2. #2
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    Hi Bill!

    Try
    Code:
    Print #1, " testing"
    from child too, while the file #1 is open. It works.

    But the best approach is to add a public method in parent (say LogFile), something like:
    Code:
    Public Sub LogFile(strText As String)
        'Procedure in parent's code module.
        Dim lngFile As Long
        
        lngFile = FreeFile
        Open "c:\LogFile.txt" For Append As lngFile
        Print #lngFile, strText
        Close lngFile
    End Sub
    Then, from the child’s module, you can say:
    Code:
    Me.Parent.LogFile "Hi! This is your child!"
    Cheers,
    John

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Code:
    Print #1, " testing"
    Well, that is simple enough. I had Parent/Child on the brain this morning, not thinking Access would recognize the open file.
    Thanks,
    Bill

  4. #4
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    You are welcome!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 10-26-2015, 06:14 AM
  2. Parent-child relations
    By Dida in forum Access
    Replies: 8
    Last Post: 08-19-2015, 01:24 PM
  3. Replies: 7
    Last Post: 01-21-2014, 11:32 AM
  4. Replies: 3
    Last Post: 07-03-2013, 01:20 PM
  5. Child/Parent relationship
    By ErnieS in forum Forms
    Replies: 1
    Last Post: 08-20-2010, 01:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums