Allowing Make Table Query overwriting existing table in mdb via adodb connection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arcingmad
    New Member
    • Sep 2007
    • 1

    Allowing Make Table Query overwriting existing table in mdb via adodb connection

    Hi I am using the following code in a button click event to run a query stored in a .mdb file from an external geographic program ArcGIS via a jet adodb connection

    I have the need to run an existing make table query, my problem is it will over write an existing table. i.e when run in access a warning that you are about to overwrite an existing table will be shown and you will be prompted to accept or reject. When run via the external program using the method below a run time error occurs saying the table to be overwriten already exists. I am unsure how to access the Accept reject overwrite function via the external program if it is possible at all. Any ideas on how to hand this error would be greatly appreciated

    Code:
    Dim strConnectionString As String
    Dim objConn As ADODB.Connection
    Dim objCommand As ADODB.Command
    
    strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Database.mdb;" & _
    "Jet OLEDB:Engine Type=4"
    
    Set objConn = New ADODB.Connection
    objConn.Open strConnectionString
    
    Set objCommand = New ADODB.Command
    
    objCommand.ActiveConnection = objConn
    
    ' Assign to ADO Command object
    objCommand.CommandText = "QRY_ONE"
    objCommand.CommandType = adCmdStoredProc
    
    objCommand.Execute
    
    objConn.Close
    
    Set objCommand = Nothing
    Set objConn = Nothing
    Thanks
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Why not just trap the "already exists" error, prompt the user, and if they say to go ahead, delete the existing table first? That's probably all that Access does.

    Comment

    Working...