lyleatmark
MIS
Can you help me make this VBA code work with access 2000? It work with a 97 applicationbut when i convert in to 2000 it goes straignt to "Invalid Password, try again!"
Private Sub cmdLogon_Click()
'check for correct UserName and password
Dim SQL As String
Dim recUsers As Recordset
Dim recAudit As Recordset
Dim swarning As String
Dim dbCorporateActions As Database
'Public User As String
swarning = "Warning"
txtUserName.SetFocus
User = " & txtUserName.Text & "
SQL = "SELECT * From Users Where Usrname = '" & txtUserName.Text & "'"
Set dbCorporateActions = CurrentDb
Set recUsers = dbCorporateActions.OpenRecordset(SQL, dbOpenDynaset)
Set recAudit = dbCorporateActions.OpenRecordset("Audit")
If recUsers.RecordCount <> 0 Then
txtPassword.SetFocus
If txtPassword.Text = recUsers!password Then
'Store User Info
With recAudit
.AddNew
!UsrName = recUsers!UsrName
!UserID = recUsers!UserID
!Created = Now
!Firstname = recUsers!Firstname
!Lastname = recUsers!Lastname
.Update
.Bookmark = .LastModified
End With
DoCmd.Close acForm, "Logon", acSaveYes
DoCmd.OpenForm "SwitchBoard", acNormal, , , acFormEdit, acWindowNormal
Else
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.SetFocus
txtPassword.SelStart = 0
txtPassword.SelLength = Len(txtPassword.Text)
End If
Else
MsgBox "This user does not exist.", vbCritical, swarning
txtUserName.Text = ""
txtUserName.SetFocus
End If
End Sub
Private Sub cmdLogon_Click()
'check for correct UserName and password
Dim SQL As String
Dim recUsers As Recordset
Dim recAudit As Recordset
Dim swarning As String
Dim dbCorporateActions As Database
'Public User As String
swarning = "Warning"
txtUserName.SetFocus
User = " & txtUserName.Text & "
SQL = "SELECT * From Users Where Usrname = '" & txtUserName.Text & "'"
Set dbCorporateActions = CurrentDb
Set recUsers = dbCorporateActions.OpenRecordset(SQL, dbOpenDynaset)
Set recAudit = dbCorporateActions.OpenRecordset("Audit")
If recUsers.RecordCount <> 0 Then
txtPassword.SetFocus
If txtPassword.Text = recUsers!password Then
'Store User Info
With recAudit
.AddNew
!UsrName = recUsers!UsrName
!UserID = recUsers!UserID
!Created = Now
!Firstname = recUsers!Firstname
!Lastname = recUsers!Lastname
.Update
.Bookmark = .LastModified
End With
DoCmd.Close acForm, "Logon", acSaveYes
DoCmd.OpenForm "SwitchBoard", acNormal, , , acFormEdit, acWindowNormal
Else
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.SetFocus
txtPassword.SelStart = 0
txtPassword.SelLength = Len(txtPassword.Text)
End If
Else
MsgBox "This user does not exist.", vbCritical, swarning
txtUserName.Text = ""
txtUserName.SetFocus
End If
End Sub