Results 1 to 4 of 4
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Saving report IDs to a text file

    I am running some VBA and I would like to log each ID not used in a do until in a text file

    so I know how to create a path etc

    I would like to create a text file, log the id into that text file on a new line (just for easier reading) and then move to the next record to do the same



    my question I guess is how do I insert data into the text file without overwriting the whole file?

  2. #2
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Great! It seems to work fine however I wouldn't mind if someone had a look at it to check I have things in order (hoping it looks ok)

    Code:
                       
     'check to see if the folder exists and create one if it doesn't                   
     If Dir("C:\AccessLogs", vbDirectory) = "" Then
                        MkDir ("C:\AccessLogs")
                        Set fs = CreateObject("Scripting.FileSystemObject")
                        Set txFile1 = fs.CreateTextFile("c:\AccessLogs\Employee.txt", True)
                        txFile1.WriteLine ("Created file on " & Date)
                        txFile1.Close
                        Else
                        End If
                        
                        'write to a text file
                        intFileNum = FreeFile()
                        Open "C:\AccessLogs\Employee.txt" For Append As #intFileNum
                        Write #intFileNum, "School ID " & rs!NewSchoolsID & " was sent (including confirmations) on " & Date
                        Close #intFileNum

  4. #4
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Looks good to me. The proof is whether it works or not.

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

Similar Threads

  1. Replies: 15
    Last Post: 07-10-2013, 01:27 PM
  2. Replies: 1
    Last Post: 02-22-2013, 09:39 PM
  3. Replies: 3
    Last Post: 03-19-2012, 06:10 PM
  4. Replies: 21
    Last Post: 01-24-2012, 06:21 PM
  5. Replies: 1
    Last Post: 06-09-2011, 11:10 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