Po korakih sem prišel do spodnje kode.
Koda: Izberi vse
Option Explicit
Dim a As Byte
Dim b As Byte
Dim c As Byte
Dim d As Byte
Dim e As Byte
Dim f As Byte
Dim g As Byte
Dim x As Byte
Dim n As Long
Sub addcolumns_II()
n = 1
a = 1
b = 2
c = 3
d = 4
e = 5
f = 6
g = 7
Dim dbConnectStr As String
Dim tabela_ime As String
tabela_ime = n & "," & a & "," & b & "," & c & "," & d & "," & e & "," & f & "," & g
Dim cnt As ADODB.Connection
dbConnectStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & "C:\VBA\A\vaja.accdb"
Set cnt = New ADODB.Connection
With cnt
.Open dbConnectStr
.Execute "CREATE TABLE" & tabela_ime & "([No0] Integer," & "[No1] Byte, " & "[No2] Byte, " & "[No3] Byte, " & "[No4] Byte, " & "[No5] Byte, " & "[No6] Byte, " & "[No7] Byte)"
End With
Set cnt = Nothing
End Sub
Želel bi, da ima novo kreirana tabela ime sestavljeno iz prej definiranih spremenljivk kot je to definirano v tabela_ime.Sintaksna napaka v izjavi CREATE TABLE.
Pred več kot 10 leti mi je nekaj podobnega delovalo v Excel VBA 2003.
?
lp