Hey everyone.
I have the code for creating a database in Access. But when the code gets to "Creating the table", I get an error (picture attached).
Here is my code (it worked 10 months ago..). It should create the file, and then execute a query that creates a table with some fields.
I get this error: "Run-time error '3704': Operation is not allowed when the object is closed."
If I add "conexiune_cu_date.Open", I get another error: Run-time error '-2147467259 (80004005)': [Microsoft][ODBC Manager] Data source name not found and no default driver specified."
Thank you in advance
I have the code for creating a database in Access. But when the code gets to "Creating the table", I get an error (picture attached).
Here is my code (it worked 10 months ago..). It should create the file, and then execute a query that creates a table with some fields.
Code:
Sub CreateDatabase()
'Scop Macro: Creaza o baza de date de acces
Dim conexiune_database As String
Dim informatii_catalog As Object
Dim conexiune_cu_date As ADODB.Connection
Dim locatie_database As String
'numele bazei de date
locatie_database = "E:" & Application.UserName & ".mdb" '(adica numele utilizatorului)
conexiune_database = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & locatie_database & ";"
'Creeare baza de date noua
Set informatii_catalog = CreateObject("ADOX.Catalog")
informatii_catalog.Create conexiune_database
Set informatii_catalog = Nothing
'conectare si introducere date
Set conexiune_cu_date = New ADODB.Recordset
'conexiune_cu_date.Open
With conexiune_cu_date
.Execute "CREATE TABLE powerbi ([build_number] text(150) WITH Compression, " & _
"[race_type] text(150) WITH Compression, " & _
"[race_number] text(50) WITH Compression, " & _
"[platform] text(100) WITH Compression, " & _
"[tier] text(50) , " & _
"[network] text(100) , " & _
"[speed] text(100) , " & _
"[latency] text(100) WITH Compression, " & _
"[device] text(100) WITH Compression, " & _
"[firmware] text(50)) " & _
"[rating] text(100) WITH Compression, " & _
"[notes_observations] text(100) WITH Compression), "
End With
Set conexiune_cu_date = Nothing
End Sub
I get this error: "Run-time error '3704': Operation is not allowed when the object is closed."
If I add "conexiune_cu_date.Open", I get another error: Run-time error '-2147467259 (80004005)': [Microsoft][ODBC Manager] Data source name not found and no default driver specified."
Thank you in advance