473,569 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Newpa ssword 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 4096
MMcCarthy
14,534 Recognized Expert Moderator MVP
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,564 Recognized Expert Moderator MVP
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,564 Recognized Expert Moderator MVP
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.NewPa ssword Old, New. This works.
Oct 13 '10 #6
NeoPa
32,564 Recognized Expert Moderator MVP
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.NewPa ssword 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,564 Recognized Expert Moderator MVP
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
1603
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 thing. I am using the FPSE method wthin VS.NET 2003
4
7706
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 on the subform that recieves the focus. The basic steps of the macro are:
4
35746
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 is because suppose if i will upload 20GB means it will take time to store it in servers disk, definitely there is a loss of session during this process...
2
2086
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 type system.invalidoperation exception occured in system.data.dll additional information:update requires a valid updatecommand when passed datarow...
2
1826
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 these parameters are to b handled in the destination page? please help...
8
1548
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 (parameter one). I tried this: public static int findInString (String text1, String text2) { int length1 = text1.length(); int length2 =...
5
13959
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 button? I searched a few things on Google but I find the javascript below most useful in my case but there is some problem that my code is not running: ...
7
1946
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 owner ; private int size ; private QueueNode next ; private QueueNode previous ;
2
2251
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. Please help. Thank you
0
1356
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 generate a report. Actually i have first selected ASP.NET website with c# language , then i added a crystal report using add item in solution explorer...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7678
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6286
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.