2
這個想法是在表單字段中輸入新表的名稱,然後單擊一個按鈕在遠程數據庫上創建一個表,用戶輸入該字段的名稱。但是,新表使用名稱「NewTableName」創建,而不是NewTableName字段中的值。有誰知道不同的語法或更好的功能?提前致謝!訪問創建表vba
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
不要忘了在方括號中如果添加用戶可能鍵入一個空格名稱... – 2013-04-11 20:01:54
謝謝!好決定! – 2013-04-11 20:06:05
很簡單!謝謝! – James 2013-04-11 20:10:11