M
Martin
I have the below code that checks to see if a user has a blank password.
That section works. My problem is the else loop. No matter what password I
set for myself, I still get error 3029. My default password is "MARINES" and
I want to force users to change their default password.
My question is can I do it through code?
Thank you for your time and help.
Private Sub Form_Open(Cancel As Integer)
Dim ws As Workspace
Dim myset As Recordset
Dim db As Database
Dim iPerm As Integer
Dim iStud As Integer
On Error Resume Next
Set ws = DBEngine.CreateWorkspace("tempws", CurrentUser(), "")
Debug.Print CurrentUser()
Debug.Print err.number
If err = 0 Then
MsgBox "Your PASSWORD is blank. This will not be tolerated! Your
access to the dbase will be TERMINATED if not fixed NOW.", vbCritical
'users has a blank password
Set db = CurrentDb
Set myset = db.OpenRecordset("tblUsers", dbOpenTable)
myset.Index = "UserName"
myset.Seek "=", CurrentUser()
If myset.NoMatch Then
'Stop No matching record
MsgBox "No Matching UserName record", vbCritical
Else
'Stop found matching record
Debug.Print myset!UserName
myset.Edit
myset!BLANKPASSWORD = -1
myset.Update
End If
Else
' Stop
'users password is not blank
'check to see if it is still the default
Set ws = DBEngine.CreateWorkspace("tempws", CurrentUser(), "MARINES")
Debug.Print err.number, err.Description 'error = 3029 Not a valid
account name or password.
If err = 0 Then
'Stop 'user PASSWORD is still default
MsgBox "Your PASSWORD is still the default. Please change your
password or you will loose your access to the company dbase. Don't know how.
Call 8582 and talk to Mr. Cox.", vbCritical
Else
'Stop 'user has changed their password
MsgBox "Thank you for changing your PASSWORD. ", vbCritical
End If
End If
That section works. My problem is the else loop. No matter what password I
set for myself, I still get error 3029. My default password is "MARINES" and
I want to force users to change their default password.
My question is can I do it through code?
Thank you for your time and help.
Private Sub Form_Open(Cancel As Integer)
Dim ws As Workspace
Dim myset As Recordset
Dim db As Database
Dim iPerm As Integer
Dim iStud As Integer
On Error Resume Next
Set ws = DBEngine.CreateWorkspace("tempws", CurrentUser(), "")
Debug.Print CurrentUser()
Debug.Print err.number
If err = 0 Then
MsgBox "Your PASSWORD is blank. This will not be tolerated! Your
access to the dbase will be TERMINATED if not fixed NOW.", vbCritical
'users has a blank password
Set db = CurrentDb
Set myset = db.OpenRecordset("tblUsers", dbOpenTable)
myset.Index = "UserName"
myset.Seek "=", CurrentUser()
If myset.NoMatch Then
'Stop No matching record
MsgBox "No Matching UserName record", vbCritical
Else
'Stop found matching record
Debug.Print myset!UserName
myset.Edit
myset!BLANKPASSWORD = -1
myset.Update
End If
Else
' Stop
'users password is not blank
'check to see if it is still the default
Set ws = DBEngine.CreateWorkspace("tempws", CurrentUser(), "MARINES")
Debug.Print err.number, err.Description 'error = 3029 Not a valid
account name or password.
If err = 0 Then
'Stop 'user PASSWORD is still default
MsgBox "Your PASSWORD is still the default. Please change your
password or you will loose your access to the company dbase. Don't know how.
Call 8582 and talk to Mr. Cox.", vbCritical
Else
'Stop 'user has changed their password
MsgBox "Thank you for changing your PASSWORD. ", vbCritical
End If
End If