我们的想法是在表单字段中键入新表的名称,然后单击按钮以使用用户在该字段中输入的名称在远程数据库上创建表。但是,新表的名称为“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
答案 0 :(得分:2)
创建一个等于他们输入表名的文本框的text属性的变量。然后说出如下内容:
"CREATE TABLE [" + variable + "] (Question Text, ID COUNTER)"