想法是在表单字段中输入新表的名称,然后单击按钮以在远程数据库上使用用户输入字段的名称创建表。但是,新表是使用名称“NewTableName”而不是 NewTableName 字段中的值创建的。有谁知道不同的语法或更好的功能?提前致谢!
Private Sub MakeTable_Click()
Dim dbConnectStr As String
Dim Catalog As Object
Dim cnt As ADODB.Connection
Dim dbPath As String
dbPath = "\\JAMWHITL-WS01\AccessBackEnds\Assessments\AssessmentsBackEnd.accdb"
dbConnectStr = "Driver={Microsoft Access Driver (*.mdb, *.accdb)}; Dbq=" & dbPath & ";"
Set cnt = New ADODB.Connection
With cnt
.Open dbConnectStr
.Execute "CREATE TABLE [NewTableName] (Question Text, ID COUNTER)"
End With
Set cnt = Nothing
End Sub