Solved

rename table column names runtime error

Posted on 2010-09-06
6
472 Views
Last Modified: 2013-11-27
on this line
con.open currentproject.accessconnection

I get runtime error '-2147467259 (80004005)':

the database has been placed in a state by user 'admin' on machine
'fuj1' that prevents it from being opened or locked.




Private Sub Command6_Click()



   'Create a Catalog object

   

   Dim con As New ADODB.Connection

   con.Open CurrentProject.AccessConnection

   

   Dim Cat As New ADOX.Catalog

   Cat.ActiveConnection = con

 

 Dim oldn As String

 Dim newn As String

 Dim tbln As String

 

tbln = "test"

oldn = "dog101"

newn = "dog"



   'Create a table object

   

   Dim Tbl As ADOX.Table

   Set Tbl = New ADOX.Table

  

   Set Tbl = Cat.Tables(tbln)

   Tbl.Columns(oldn).Name = newn

 

   Set Cat = Nothing

   Set Tbl = Nothing





End Sub

Open in new window

0
Comment
Question by:slothnet
6 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 33613965
how about using dao to change it eg

 CurrentDb.TableDefs(tbln).Fields(oldn).Name = newn
0
 
LVL 3

Expert Comment

by:fabalou
ID: 33614027
Check that there is no pending saves to be done to the schema before that code runs. If there is anything that needs to be saved (code edits), form edits e.t.c it can all produce that error.
0
 

Author Comment

by:slothnet
ID: 33614064
I restarted the database and now I get run-time error 3251

object or provider is not capable of performing requested operation
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:slothnet
ID: 33614066
on this line

  Tbl.Columns(oldn).Name = newn
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 33614083


test thiscodes

Dim oldn As String
Dim newn As String
Dim tbln As String
Dim tbl As ADOX.Table
Dim cat As New ADOX.Catalog
Set cat.ActiveConnection = CurrentProject.Connection
 
tbln = "test"
oldn = "dog101"
newn = "dog"
cat.Tables(tbln).Columns(oldn).Name = newn
 
   Set cat = Nothing
   Set tbl = Nothing
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33614097
and how did you define tbl? I showed you a dao example so tbl as to be defined as dao.tabledef

the code I gave is not compatible with using adox
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now