Tuesday, 17 October 2017

Best Fixes To Resolve Access Database "Not A Valid Password" Error



Does you too encountering the "Needs to be repaired" and "Not a valid password" in your Access application? You might be surprised after getting such an error after setting out password in Microsoft database file.


Sometime such situation arises when after setting password in Microsoft access database, as you try to login with the same password you may not be able to login. Not only this you will also get the following error 

"Needs to be repaired" and "Not a valid password"
 However your password is correct but still you are unable to unlock MS Access Database File.

Reason: why Access shows "Not a valid password" error?

The reason for the occurrence of this Access "Needs to be repaired" and "Not a valid password" is the incorrect password format. If you recently set your access database password and your password ends with backslash character(\) then MS database denies you to login with that password and throws such “Not a valid password” error.

How To Recover Or Reset .mdb/.accdb Access Database File Password?

Well there is no such way to reset your access database .mdb/accdb file password. But if you are having knowledge of programming then you can get back your database again by. For this you just need to follow these steps.

You just need to create a new database and import objects of old one to new one.


Before writing the code, take the reference of the Microsoft DAO 3.5 Object Library. In order to take the reference follows the below mentioned steps.

Click on the Tools menu in Visual Basic Editor
Click on Reference
Check the Microsoft DAO 3.6 Object Library Checkbox

After this, write the following code in the visual basic editor and debug the code. But before debugging this code, replace your old password with the password mentioned in the code.

Option Compare Database
Option Explicit
Public Function ImportDb(strPath As String) As Boolean
On Error Resume Next
Dim db As Database 'Database to import.
Dim td As TableDef 'Table definitions in the database.
Dim strTDef As String 'Name of the table or the query to import.
Dim qd As QueryDef 'Query definitions in the database.
Dim doc As Document 'Documents in the database.
Dim strCntName As String 'Document container name.
Dim x As Integer 'For looping.
Dim cntContainer As Container 'Containers in the database.
Dim strDocName As String 'Name of the document.
Dim intConst As Integer
Dim cdb As Database 'Current database.
Dim rel As Relation 'Relation to copy.
Dim nrel As Relation 'Relation to create.
Dim strRName As String 'Copied relation's name.
Dim strTName As String 'Relation table name.
Dim strFTName As String 'Relation foreign table name.
Dim varAtt As Variant 'Attributes of the relation.
Dim fld As Field 'Field(s) in the relation to copy.
Dim strFName As String 'Name of the field to append.
Dim strFFName As String 'Foreign name of the field to append.
'Open the database that contains objects to import.
Set db = DBEngine.Workspaces(0).OpenDatabase(strPath, False, False, "MS Access;PWD=")
'Import tables from the specified Access database.
For Each td In db.TableDefs
strTDef = td.Name
If Left(strTDef, 4) <> "MSys" Then
DoCmd.TransferDatabase acImport, "Microsoft Access", strPath, acTable, _ strTDef, strTDef, False
End If
Next
'Import queries.
For Each qd In db.QueryDefs
strTDef = qd.Name
DoCmd.TransferDatabase acImport, "Microsoft Access", strPath, acQuery, _ strTDef, strTDef, False
Next
'Copy relationships to the current database.
Set cdb = CurrentDb
For Each rel In db.Relations
With rel
'Get the properties of the relation to copy.
strRName = .Name
strTName = .Table
strFTName = .ForeignTable
varAtt = .Attributes
'Create a relation in the current database with the same properties.
Set nrel = cdb.CreateRelation(strRName, strTName, strFTName, varAtt)
For Each fld In .Fields
strFName = fld.Name
strFFName = fld.ForeignName
nrel.Fields.Append nrel.CreateField(strFName)
nrel.Fields(strFName).ForeignName = strFFName
Next
cdb.Relations.Append nrel
End With
Next
'Loop through the containers and import all documents.
For x = 1 To 4
Select Case x
Case 1
strCntName = "Forms"
intConst = acForm

Case 2
strCntName = "Reports"
intConst = acReport

Case 3
strCntName = "Scripts"
intConst = acMacro

Case 4
strCntName = "Modules"
intConst = acModule
End Select
Set cntContainer = db.Containers(strCntName)
For Each doc In cntContainer.Documents
strDocName = doc.Name
DoCmd.TransferDatabase acImport, "Microsoft Access", strPath, intConst, _ strDocName, strDocName
'Debug.Print strDocName 'for debugging will list document names in the Debug window.
Next doc
Next x
'Clean up variables to recover memory.
Set fld = Nothing
Set nrel = Nothing
Set rel = Nothing
Set cdb = Nothing
Set td = Nothing
Set qd = Nothing
Set cntContainer = Nothing
db.Close
Set db = Nothing
msgbox "The database has been imported successfully."
ImportDb = True
End Function 

For debugging this code, just go to the immediate window and write down the following command after then press enter. 

?ImportDb("<Full path of your Access database>") 

After successfully running this code, now you can use your newly created database with your old data.

Automatic Solution For Access Password Recovery:

If you don’t wants to go with the manual or programmatic code then also you need not to worry just try the Access Repair And Recovery tool. As, it is the simplest and easiest way to recover up your lost Access Database password.



This is the most appropriate software that is particularly designed to repair corrupt or damaged MS Access database files. It comes with powerful algorithm that scans even severely corrupted access database files. It also has highly interactive GUI that helps user to easily operate and repair Access database without making changes in the original structure of the file. It easily restores damage or corrupt tables, queries, indexes and other data. 

0 comments:

Post a Comment