Önce Tablo Yap Sonra Yeni Acces Dosyası Oluştur.

Katılım
19 Şubat 2006
Mesajlar
73
Excel Vers. ve Dili
exel
Merhabalar

Yeni bir sorgu oluşturdum oluşturduğum sorgu tabloyap sorgusu bu sorgu ile mevcut veritabanın içine yeni bir tablo oluşturabiliyorum oysaki benim istediğim oluşacak bu yeni tablo ile yeni bir access dosyası oluşturmak. yani çalıştığımız veritabınından bağımsız fakat tabloyap sorgusu ile elde edilecek tabloyu içeren yeni bir access dosyasını komutla nasıl oluşturabilirim.

Uzun yolu oluşan tabloyu yeni bir acces dosyası açıp kopyalamak ama mutlaka kısa bir yolu vardır diye düşünüyorum.

teşekkürler
 

Ekli dosyalar

Katılım
25 Aralık 2005
Mesajlar
4,160
Excel Vers. ve Dili
MS Office 2010 Pro Türkçe
Sayın smmustafa,

İstediğiniz kodlar:

Kod:
Private Sub CreateDatabase()

'Macro Purpose: Create an Access database on the fly

    Dim dbConnectStr As String
    Dim Catalog As Object
    Dim cnt As ADODB.Connection
    Dim dbPath As String

    'Set database name here
    dbPath = "C:\" & Application.UserName & ".mdb"
    dbConnectStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath & ";"

    'Create new database
    Set Catalog = CreateObject("ADOX.Catalog")
    Catalog.Create dbConnectStr
    Set Catalog = Nothing

    'Connect to database and insert a new table
    Set cnt = New ADODB.Connection
    With cnt
        .Open dbConnectStr
        .Execute "CREATE TABLE tblSample ([Name] text(50) WITH Compression, " & _
                 "[Address] text(150) WITH Compression, " & _
                 "[City] text(50) WITH Compression, " & _
                 "[ProvinceState] text(2) WITH Compression, " & _
                 "[Postal] text(6) WITH Compression, " & _
                 "[Account] decimal(6))"
    End With
    Set cnt = Nothing

End Sub
İyi çalışmalar
 
Üst