Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 202
Default Working with Access Dabatabases through VBA Codes in Excel

I'm working with Access Databases through VBA codes from Excel, but I have a
problem when typing "DROP TABLE MYTable;" (In the case that table doesn't
exist)

Then, how know if MYTable exists, before writing the instruction DROP TABLE.

I write them my example:

Dim cnn As New ADODB.Connection
Set cnn = New Connection
dbName = ("C:\Data\MYDataBase1.mdb")
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Mode = adModeWrite
.Properties("Jet OLEDB:Database Password") = "abc"
.Open dbName
End With

'Create the recordset
Dim rs As ADODB.Recordset
Set rs = New Recordset

'Determines what records to show
Dim strSQL As String
strSQL = "DROP TABLE MYTABLE;"

'Retreive the records
rs.CursorLocation = adUseClient
rs.Open strSQL, cnn

'close connection
cnn.Close
Set cnn = Nothing
Set rs = Nothing

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel link to access query not working richard Excel Discussion (Misc queries) 0 February 19th 09 06:11 AM
Excel Quick Access Toolbar Commands not working? Jerry H Excel Discussion (Misc queries) 3 July 16th 08 08:11 PM
vlookup with zip codes - not working - frustrated chrissyb Excel Worksheet Functions 3 April 10th 07 04:43 AM
Lookups in Excel on Data from Access not working goldcd_2 Excel Worksheet Functions 2 January 31st 07 06:01 PM
Working with protected Databases Access through Excel Dennis Excel Programming 2 August 16th 05 10:36 PM


All times are GMT +1. The time now is 01:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"