Results 1 to 2 of 2
  1. #1
    DubCap01 is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Sep 2014
    Location
    Dubbo, Australia
    Posts
    104

    Stopping Code if a table exists

    Hi all,

    I want to be able to trap the existence of a table in the database once I have imported 5 text files, and then act accordingly.

    I know that a particular text file (episode.txt) has 1 of 150 records with the following error in the file format:
    "Previous",""ErrorFieldDoubleQuotes"","nextf" which obviously will not parse on import
    and I know that when I import it, then a table [episode_ImportErrors] is created, and that 1 in 150 is listed.



    Is there a way of then recognising that the table [episode_ImportErrors] has been created, and stop my code? I tried the following code, which works, but if I remove the error from the episode.txt file (and physically delete the error table) and run the code again, the code still invokes and I get the message box!!

    Code:
            DoCmd.SetWarnings False
            If DCount("*", "episode_ImportErrors") > 0 Then
                    MsgBox "There is at least one fatal error in the episode.txt file structure", vbCritical, "FATAL ERROR"
                    Cancel = True
                    Exit Sub
            DoCmd.SetWarnings True
            End If
    thanks in anticipation folks!

    Pete

  2. #2
    DubCap01 is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Sep 2014
    Location
    Dubbo, Australia
    Posts
    104
    All sorted folks, found this code to use and it works fine!
    Code:
    If Not IsNull(DLookup("Name", "MSysObjects", "Name='episode_ImportErrors'")) Then
    cheers
    Pete

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

Similar Threads

  1. Replies: 1
    Last Post: 01-18-2017, 10:29 AM
  2. Replies: 1
    Last Post: 03-31-2016, 03:33 AM
  3. Code to return 'No Record exists'
    By coach32 in forum Programming
    Replies: 2
    Last Post: 07-28-2015, 07:29 AM
  4. Stopping code on fail
    By DubCap01 in forum Programming
    Replies: 5
    Last Post: 03-06-2015, 08:11 PM
  5. VBA code to check if a record already exists
    By fra90 in forum Programming
    Replies: 3
    Last Post: 11-20-2013, 11:20 AM

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