M
Max
I am using DAO to create a new table in an external database that I have full design permissions on. I am using the sample code in Access 97 with a few minor alterations so far. When it is run from the Debug window with
CreateOpNoteTable "C:\LOGBOOK\LOGTEMP97.MDB"
The error is "You do not have permission to use the "C:\LOGBOOK\LOGTEMP97.MDB" object.
Any ideas?
Thanks in advance for any help offered.
Max
Code as follows:
Sub CreateOpNoteTable(strDBName)
'This creates a new table in an external database using DAO and adds the fields
'and adds the table name to the A_Table list
'
'Called using CreateOpNoteTable "C:\LOGBOOK\LOGDAT97.MDB"
Dim dbsLogdat As Database
Dim tdfNew As TableDef
Dim prpLoop As Property
Set dbsLogdat = OpenDatabase(strDBName)
' Create a new TableDef object.
Set tdfNew = dbsLogdat.CreateTableDef("PatientOpNoteTemp")
With tdfNew
' Create fields and append them to the new TableDef
' object. This must be done before appending the
' TableDef object to the TableDefs collection of the
' Logdat database.
..Fields.Append .CreateField("FirstName", dbText)
.Fields.Append .CreateField("LastName", dbText)
.Fields.Append .CreateField("Phone", dbText)
.Fields.Append .CreateField("Notes", dbMemo)
Debug.Print "Properties of new TableDef object " & _
"before appending to collection:"
' Enumerate Properties collection of new TableDef
' object.
For Each prpLoop In .Properties
On Error Resume Next
If prpLoop <> "" Then Debug.Print " " & _
prpLoop.Name & " = " & prpLoop
On Error GoTo 0
Next prpLoop
' Append the new TableDef object to the Northwind
' database.
dbsLogdat.TableDefs.Append tdfNew
Debug.Print "Properties of new TableDef object " & _
"after appending to collection:"
CreateOpNoteTable "C:\LOGBOOK\LOGTEMP97.MDB"
The error is "You do not have permission to use the "C:\LOGBOOK\LOGTEMP97.MDB" object.
Any ideas?
Thanks in advance for any help offered.
Max
Code as follows:
Sub CreateOpNoteTable(strDBName)
'This creates a new table in an external database using DAO and adds the fields
'and adds the table name to the A_Table list
'
'Called using CreateOpNoteTable "C:\LOGBOOK\LOGDAT97.MDB"
Dim dbsLogdat As Database
Dim tdfNew As TableDef
Dim prpLoop As Property
Set dbsLogdat = OpenDatabase(strDBName)
' Create a new TableDef object.
Set tdfNew = dbsLogdat.CreateTableDef("PatientOpNoteTemp")
With tdfNew
' Create fields and append them to the new TableDef
' object. This must be done before appending the
' TableDef object to the TableDefs collection of the
' Logdat database.
..Fields.Append .CreateField("FirstName", dbText)
.Fields.Append .CreateField("LastName", dbText)
.Fields.Append .CreateField("Phone", dbText)
.Fields.Append .CreateField("Notes", dbMemo)
Debug.Print "Properties of new TableDef object " & _
"before appending to collection:"
' Enumerate Properties collection of new TableDef
' object.
For Each prpLoop In .Properties
On Error Resume Next
If prpLoop <> "" Then Debug.Print " " & _
prpLoop.Name & " = " & prpLoop
On Error GoTo 0
Next prpLoop
' Append the new TableDef object to the Northwind
' database.
dbsLogdat.TableDefs.Append tdfNew
Debug.Print "Properties of new TableDef object " & _
"after appending to collection:"