• If Exists Drop Table in Access

    Author
    Topic
    #465735

    looking into this, thought i’d swing by the lounge…

    in SQL Server, you often do things like If Exists

    Drop Table
    as a standard check prior to trying to create the object. In Access, I have tabledef code in place and I want to do the same check to make sure I never try to create a table def if the linked table already exits.

    So, looking for the syntax…

    TIA!

    Viewing 22 reply threads
    Author
    Replies
    • #1198664

      looking into this, thought i’d swing by the lounge…

      in SQL Server, you often do things like If Exists

      Drop Table
      as a standard check prior to trying to create the object. In Access, I have tabledef code in place and I want to do the same check to make sure I never try to create a table def if the linked table already exits.

      So, looking for the syntax…

      TIA!

    • #1199191

      looking into this, thought i’d swing by the lounge…

      in SQL Server, you often do things like If Exists

      Drop Table
      as a standard check prior to trying to create the object. In Access, I have tabledef code in place and I want to do the same check to make sure I never try to create a table def if the linked table already exits.

      So, looking for the syntax…

      TIA!

    • #1200258

      looking into this, thought i’d swing by the lounge…

      in SQL Server, you often do things like If Exists

      Drop Table
      as a standard check prior to trying to create the object. In Access, I have tabledef code in place and I want to do the same check to make sure I never try to create a table def if the linked table already exits.

      So, looking for the syntax…

      TIA!

    • #1201130

      looking into this, thought i’d swing by the lounge…

      in SQL Server, you often do things like If Exists

      Drop Table
      as a standard check prior to trying to create the object. In Access, I have tabledef code in place and I want to do the same check to make sure I never try to create a table def if the linked table already exits.

      So, looking for the syntax…

      TIA!

    • #1201971

      looking into this, thought i’d swing by the lounge…

      in SQL Server, you often do things like If Exists

      Drop Table
      as a standard check prior to trying to create the object. In Access, I have tabledef code in place and I want to do the same check to make sure I never try to create a table def if the linked table already exits.

      So, looking for the syntax…

      TIA!

    • #1202726

      looking into this, thought i’d swing by the lounge…

      in SQL Server, you often do things like If Exists

      Drop Table
      as a standard check prior to trying to create the object. In Access, I have tabledef code in place and I want to do the same check to make sure I never try to create a table def if the linked table already exits.

      So, looking for the syntax…

      TIA!

    • #1203611

      looking into this, thought i’d swing by the lounge…

      in SQL Server, you often do things like If Exists

      Drop Table
      as a standard check prior to trying to create the object. In Access, I have tabledef code in place and I want to do the same check to make sure I never try to create a table def if the linked table already exits.

      So, looking for the syntax…

      TIA!

    • #1198084

      This code could be quickly modified to suit your situation.

      Dim RemoveDB As Database
      Dim strTempTbl As String
      Dim TempTableName As String

      Dim I As Integer

      Set RemoveDB = DBEngine.Workspaces(0).Databases(0)
      TempTableName = “tblTemp” & CurrentUser()

      For I = 0 To RemoveDB.TableDefs.Count – 2
      strTempTbl = RemoveDB.TableDefs(I).Name
      ‘—–Debug.Print strTempTbl
      ‘—–MsgBox “Table Name(” & i & “) = ” & strtblname

      If strTempTbl Like TempTableName Then
      RemoveDB.TableDefs.Delete strTempTbl

      End If

      Next I

      Hope this helps.

    • #1198697

      This code could be quickly modified to suit your situation.

      Dim RemoveDB As Database
      Dim strTempTbl As String
      Dim TempTableName As String

      Dim I As Integer

      Set RemoveDB = DBEngine.Workspaces(0).Databases(0)
      TempTableName = “tblTemp” & CurrentUser()

      For I = 0 To RemoveDB.TableDefs.Count – 2
      strTempTbl = RemoveDB.TableDefs(I).Name
      ‘—–Debug.Print strTempTbl
      ‘—–MsgBox “Table Name(” & i & “) = ” & strtblname

      If strTempTbl Like TempTableName Then
      RemoveDB.TableDefs.Delete strTempTbl

      End If

      Next I

      Hope this helps.

    • #1199255

      This code could be quickly modified to suit your situation.

      Dim RemoveDB As Database
      Dim strTempTbl As String
      Dim TempTableName As String

      Dim I As Integer

      Set RemoveDB = DBEngine.Workspaces(0).Databases(0)
      TempTableName = “tblTemp” & CurrentUser()

      For I = 0 To RemoveDB.TableDefs.Count – 2
      strTempTbl = RemoveDB.TableDefs(I).Name
      ‘—–Debug.Print strTempTbl
      ‘—–MsgBox “Table Name(” & i & “) = ” & strtblname

      If strTempTbl Like TempTableName Then
      RemoveDB.TableDefs.Delete strTempTbl

      End If

      Next I

      Hope this helps.

    • #1200291

      This code could be quickly modified to suit your situation.

      Dim RemoveDB As Database
      Dim strTempTbl As String
      Dim TempTableName As String

      Dim I As Integer

      Set RemoveDB = DBEngine.Workspaces(0).Databases(0)
      TempTableName = “tblTemp” & CurrentUser()

      For I = 0 To RemoveDB.TableDefs.Count – 2
      strTempTbl = RemoveDB.TableDefs(I).Name
      ‘—–Debug.Print strTempTbl
      ‘—–MsgBox “Table Name(” & i & “) = ” & strtblname

      If strTempTbl Like TempTableName Then
      RemoveDB.TableDefs.Delete strTempTbl

      End If

      Next I

      Hope this helps.

    • #1201221

      This code could be quickly modified to suit your situation.

      Dim RemoveDB As Database
      Dim strTempTbl As String
      Dim TempTableName As String

      Dim I As Integer

      Set RemoveDB = DBEngine.Workspaces(0).Databases(0)
      TempTableName = “tblTemp” & CurrentUser()

      For I = 0 To RemoveDB.TableDefs.Count – 2
      strTempTbl = RemoveDB.TableDefs(I).Name
      ‘—–Debug.Print strTempTbl
      ‘—–MsgBox “Table Name(” & i & “) = ” & strtblname

      If strTempTbl Like TempTableName Then
      RemoveDB.TableDefs.Delete strTempTbl

      End If

      Next I

      Hope this helps.

    • #1202049

      This code could be quickly modified to suit your situation.

      Dim RemoveDB As Database
      Dim strTempTbl As String
      Dim TempTableName As String

      Dim I As Integer

      Set RemoveDB = DBEngine.Workspaces(0).Databases(0)
      TempTableName = “tblTemp” & CurrentUser()

      For I = 0 To RemoveDB.TableDefs.Count – 2
      strTempTbl = RemoveDB.TableDefs(I).Name
      ‘—–Debug.Print strTempTbl
      ‘—–MsgBox “Table Name(” & i & “) = ” & strtblname

      If strTempTbl Like TempTableName Then
      RemoveDB.TableDefs.Delete strTempTbl

      End If

      Next I

      Hope this helps.

    • #1202759

      This code could be quickly modified to suit your situation.

      Dim RemoveDB As Database
      Dim strTempTbl As String
      Dim TempTableName As String

      Dim I As Integer

      Set RemoveDB = DBEngine.Workspaces(0).Databases(0)
      TempTableName = “tblTemp” & CurrentUser()

      For I = 0 To RemoveDB.TableDefs.Count – 2
      strTempTbl = RemoveDB.TableDefs(I).Name
      ‘—–Debug.Print strTempTbl
      ‘—–MsgBox “Table Name(” & i & “) = ” & strtblname

      If strTempTbl Like TempTableName Then
      RemoveDB.TableDefs.Delete strTempTbl

      End If

      Next I

      Hope this helps.

    • #1203693

      This code could be quickly modified to suit your situation.

      Dim RemoveDB As Database
      Dim strTempTbl As String
      Dim TempTableName As String

      Dim I As Integer

      Set RemoveDB = DBEngine.Workspaces(0).Databases(0)
      TempTableName = “tblTemp” & CurrentUser()

      For I = 0 To RemoveDB.TableDefs.Count – 2
      strTempTbl = RemoveDB.TableDefs(I).Name
      ‘—–Debug.Print strTempTbl
      ‘—–MsgBox “Table Name(” & i & “) = ” & strtblname

      If strTempTbl Like TempTableName Then
      RemoveDB.TableDefs.Delete strTempTbl

      End If

      Next I

      Hope this helps.

    • #1198140

      looks about right… thanks!

    • #1198766

      looks about right… thanks!

    • #1199474

      looks about right… thanks!

    • #1200370

      looks about right… thanks!

    • #1201295

      looks about right… thanks!

    • #1202108

      looks about right… thanks!

    • #1202819

      looks about right… thanks!

    • #1203786

      looks about right… thanks!

    Viewing 22 reply threads
    Reply To: Reply #1200370 in If Exists Drop Table in Access

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel