DAO error

M

Max

The following code worked for a while and now I get an error:

Couldn't create; no modify design permission for table or query

Any Ideas.
Thanks in advance.

Max

Sub CreateOpNoteTable(strDBName)
'This creates a new table in an external database using DAO and adds the
fields

Dim dbsLogdat As Database, tdfNew As TableDef, idx As Index, fld1 As Field
Set dbsLogdat = OpenDatabase(strDBName, False, False, ";pwd=admin")
Set tdfNew =
dbsLogdat.CreateTableDef("PatientOpNoteTemp",,,";pwd=admin"))
With tdfNew
.Fields.Append .CreateField("OpNoteID", dbLong)
Set idx = .CreateIndex("OpNoteIDIndex")
Set fld1 = idx.CreateField("OpNoteID")
fld1.Attributes = dbAutoIncrField
idx.Fields.Append fld1
idx.Required = True
idx.Unique = True
idx.Primary = True
.Indexes.Append idx
.Fields.Append .CreateField("PatientID", dbLong)
.Fields.Append .CreateField("EpisodeID", dbLong)
.Fields.Append .CreateField("OpDate", dbDate)

' Append the new TableDef object to the database.
dbsLogdat.TableDefs.Append tdfNew
End With

dbsLogdat.Close

End Sub
 
M

Max

Don't worry, I have fixed it using the following:

Set MyWs = DBEngine.Workspaces(0)
Set MyDb = MyWs.OpenDatabase(Filename, False, False, ";pwd=admin")

Max
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top