473,396 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help using NewPassword method

I'm trying to create a form that lets you change the database password using the NewPassword method on a Database object. It works when that database object is set to my 'back end' file containing all my data, but for the front end I set the database object to CurrentDb and it produces error 3188: "Could not update; currently locked by another session on this machine". As far as I'm aware, I have no other sessions open. I have the database open exclusively. And I'm using DAO. See code below:

Expand|Select|Wrap|Line Numbers
  1. Dim db As Database
  2.  
  3. Set db = CurrentDb
  4. db.NewPassword Old_Password, New_Password
  5.  
  6. Set db = OpenDatabase({Back End Path}, True, False, "MS Access;PWD=" & Old_Password)
  7. db.NewPassword Old_Password, New_Password
  8. db.Close
  9.  
  10. Set db = Nothing
  11.  
The code to change the password of the back end works fine. I've also tried using the NewPassword method on the front end from a new temporary database, while the front end is closed, and it works. I've even tried setting a password on that temporary database and using CurrentDb.Newpassword from within it and that works too, so it's a problem specific to my database front end.

Bizzarely, I had this working fine the first few times I did it yesterday! Any help would be much appreciated.
Oct 8 '10 #1
8 4070
MMcCarthy
14,534 Expert Mod 8TB
I think the problem is that you have the database opened exclusively. The opendatabase command is essentially trying to open another instance of the backend.
Oct 8 '10 #2
NeoPa
32,556 Expert Mod 16PB
Mary's right. If anyone has the database open exclusively then no-one can change the password (as it requires opening from within code, even if it is already open to you the operator). Does that make sense?
Oct 9 '10 #3
Thanks for the replies. Actually, when I use the OpenDatabase command to open an instance of the back end and change its password it works fine, despite the front end I'm doing this from having linked tables with the back end. The problem is with the front end that I am working in, I can't change the password of that.

According to this article you need to have the database opened exclusively:
http://msdn.microsoft.com/en-us/libr...ffice.10).aspx

And I've tried doing it with the database not opened exclusively and I get error 3621, "Cannot change password on a shared open database."
Oct 10 '10 #4
NeoPa
32,556 Expert Mod 16PB
Tim Smith:
Actually, when I use the OpenDatabase command to open an instance of the back end and change its password it works fine, ...
Of course it does. You sound as if you think one of us has said otherwise. In fact, your whole posts indicates perhaps you haven't really grasped what was said. Let me see if I can make it clearer.

The database needs to be opened exclusively in order to change the password. It doesn't need to be opened by an operator to do this, unless that operator uses the menu structure to effect the change. If the change is made by the code, then the code needs to open the database exclusively itself. This is hardly possible if the database is already opened by the operator, exclusively or otherwise.

If that's still not clear then in practical terms, to change the password in code, you need to run the code from somewhere other than the database you are trying to change, ensure the database is opened exclusively in the code and ensure that the database is not opened at the time the code is run. If you do that you should find it works perfectly for you.
Oct 11 '10 #5
If the change is made by the code, then the code needs to open the database exclusively itself.
But doesn't CurrentDb just mean you're using the same instance as the operator rather than opening a new one in the code?

to change the password in code, you need to run the code from somewhere other than the database you are trying to change
This isn't the case, as I've tested this and it can be done. I created a new database with a single form with two text boxes (old & new password) and one button with a single line of code: CurrentDb.NewPassword Old, New. This works.
Oct 13 '10 #6
NeoPa
32,556 Expert Mod 16PB
Tim Smith:
But doesn't CurrentDb just mean you're using the same instance as the operator rather than opening a new one in the code?
I don't believe so no. I would be happy for anyone to clarify this. I cannot claim supreme expert status on this, and the help files are not too conclusive, but that is my understanding.

Tim Smith:
I created a new database with a single form with two text boxes (old & new password) and one button with a single line of code: CurrentDb.NewPassword Old, New. This works.
I was unable to confirm this. I tried a simpler test with literal strings of the values "Old" & "New", but the result I got was the error message :
Cannot change the password on a shared open database.

I don't know what to say. My reading and experience (not that I can claim to much in this area prior to looking it up for you) indicate it won't work. I'm not saying you must be wrong, as there are many variables out there to bite us when we're not looking, but I must say what I've found, which is what I've been saying.

I'm using Access 2003 for my research in case that throws any light. I can't say if things have changed possibly for more recent versions.
Oct 14 '10 #7
I've only ever used Access 2007, I've only been using Access for a couple of years, so I don't if that makes a difference. Obviously, as you imply, there must be some variable that is allowing me to this on one database but not another. I just wish I could work out what it was!

Many thanks for your help anyway. I think I'm going to just create a separate 'utility' database for changing the password.

By the way, the error you got is the one I get when I try to use NewPassword inside a database not opened exclusively, and not the error that is befuddling me – don't know if that was to blame.
Oct 14 '10 #8
NeoPa
32,556 Expert Mod 16PB
Tim Smith:
By the way, the error you got is the one I get when I try to use NewPassword inside a database not opened exclusively, and not the error that is befuddling me – don't know if that was to blame.
I was trying to illustrate that even without the database being opened exclusively, the code could not run (IE. Even when it is opened elsewhere at all - and elsewhere in this scenario includes by the operator who is causing the code to execute).

I really can't say I have the answers here, but something I'd try before I gave up on the issue would be to see if, in the same circumstances where the code fails for you (IE. The database opened exclusively - but no code active of course - the project must be cleared and all variables reset), the manual password change process works. If it does, and I would expect it to, it would tend to indicate that the code does indeed open a separate instance of the database as far as Access is concerned, and your solution of providing a Utility database, the only viable one to be found. Does that make sense?
Oct 15 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Keith | last post by:
Is there a way to publish only one file in VS.NET 2003 using FPSE method? In FP client I can select one file at a time to publish. My web is large and it takes too long to publish the whole...
4
by: Elaine | last post by:
Hi I have created a form which contains a subform. To cut a long story short, I have created a macro that moves the focus to the subform (GoToControl) and sets a value (SetValue) in the field...
4
by: Velhari | last post by:
Hi all, We all know in GET method upto 2048 characters can be appended into URL. In the Same way what is the limit of sending data to server by using POST Method. Why asking this question...
2
by: xyzbindu | last post by:
hello, iam a student & need help regarding UPDATE method of dataadapter when i update the database using dataadpter.update(dataset,tablename) i get the following error an unhandled exception of...
2
by: sandeepk84 | last post by:
hi all... am trying to send data from one web page to another using post method.. the code is in C#.it's given in the click event of a command button. like destinationfilename.aspx?parameters how...
8
by: PvtBillPilgrim | last post by:
Hi. I just started Java and need some help with a method involving strings. I need to return the index of the start of the first occurence of one string (parameter two) in another string...
5
by: JohnDriver | last post by:
Hi, I am having a form which has a text box and 3 radio buttons. I am using GET method in Ajax to pass the value. I can pass the value of the textbox fine but how to pass the value of radio...
7
by: jomcfall97 | last post by:
hey wondering if anyone can help me with some work im doing im trying to remove a record from a queue by using a method from a class. class QueueNode { private String document ; private String...
2
by: ajmerasunny | last post by:
Hi, I have following task to implement: I have to pass username and password from first html page to second html page using POST Method and automatically submit the second html page on loading....
0
by: shwethatj | last post by:
Can anyone please help me..... In Crystal Reports , how to access data using PULL method .. I have got a table in server explorer which has 3 got fields. But i dont know how to access it and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.