for start, I most say the idea is not to change a database password, but to make a copy of it, with a New Password.

Ps.
I know the first database password....

The Code:

Private Sub CreateFirstDB(fileDB As String, dbStr As String, pass As String, Optional openTheDB As Boolean = False)
Dim tblNewC As ADOX.Table, tblNewCS As ADOX.Table, tblNewST As ADOX.Table

Set catDB = New ADOX.Catalog
Set tblNewC = New ADOX.Table
Set tblNewCS = New ADOX.Table
Set tblNewST = New ADOX.Table

catDB.Create dbStr & pass
catDB.ActiveConnection = dbStr & pass


tblNewC.Name = "Classes"
tblNewC.Columns.Append "Cls_ID", adInteger
tblNewC.Columns.Append "Cls_Name", adVarWChar, 10
tblNewC.Columns.Append "Student_ID", adInteger
tblNewC.Keys.Append "Cls_ID", adKeyPrimary Or adKeyUnique, "Cls_ID"

tblNewCS.Name = "ClassesRange"
tblNewCS.Columns.Append "Range_ID", adInteger
tblNewCS.Keys.Append "Range_ID", adKeyPrimary Or adKeyUnique, "Range_ID"
tblNewCS.Columns.Append "Range_Name", adVarWChar, 10
tblNewCS.Columns.Append "Cls_ID", adInteger

tblNewST.Name = "Students"
tblNewST.Columns.Append "Student_ID", adInteger
tblNewST.Keys.Append "Student_ID", adKeyPrimary Or adKeyUnique, "Student_ID"
tblNewST.Columns.Append "Student_Name", adVarWChar, 30

catDB.Tables.Append tblNewC
catDB.Tables.Append tblNewCS
catDB.Tables.Append tblNewST

Set tblNewC = Nothing
Set tblNewCS = Nothing
Set catDB = Nothing

If openTheDB Then OpenDB dbStr
End Sub

Public Function ChangePassword(NewPass As String) As Boolean
Dim con As ADODB.Connection, cat As ADOX.Catalog
Dim tbl As ADOX.Table
fileDB = App.Path & "\tmpDB.mdb"
CurConnection = CnnString & fileDB & ";Jet OLEDBatabase Password="
CreateFirstDB fileDB, CurConnection, NewPass, False
Set con = New ADODB.Connection
con.Open CurConnection & NewPass ' Open the temp database & copy all the tables to it
Set cat = New ADOX.Catalog
Set cat.ActiveConnection = con
For Each tbl In cat.Tables
If UCase(tbl.Type) = "TABLE" Then
If UCase(Left(tbl.Name, 4)) <> "MSYS" Then
sql = "SELECT * INTO " & tbl.Name & " IN '" & fileDB & "' FROM " & tbl.Name
'Debug.Print sql
con.Execute sql
End If
End If
Next tbl
Set cat = Nothing
Set con = Nothing
ChangePassword = True
End Function


The problem is vb tells me this error:

Table 'Classes' already exists.

now the thing is I was trying to create a new database and then copy the tables to the new database with the new password....

database is created withe the new password, tables are created in the same way as I have created the original database but no data is beign copied to the new database file with the above error...

please help!

Thanks inn advanced.