Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Works with access 97 does not work with Access 2000 2

Status
Not open for further replies.
Mar 2, 2005
10
KN
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
 
You may try to replace this:
Dim recUsers As Recordset
Dim recAudit As Recordset
By this:
Dim recUsers As DAO.Recordset
Dim recAudit As DAO.Recordset

You must have the Microsoft DAO 3.x library checked in the references.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
To discover what happens add the following line:
MsgBox "txtPassword=!" & txtPassword.Text & "!" & vbCrLf & "password=!" & recUsers!password & "!"
just before this:
If txtPassword.Text = recUsers!password Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I don't know/remember 97, but I think in later version the .Text property will give you the mask, while the .value property will give you the value.

Roy-Vidar
 
Thank you I found out if I unmask the password in the input form It works. All i need to find out how to leave it mask and still make itwork??

NAME = txtPassword=!******!
password=!123456!
 
Simply replace this:
txtPassword.SetFocus
If txtPassword.Text = recUsers!password Then
By this:
If txtPassword = recUsers!password Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Actually just replacing the .Text with .Value works.

Thanks PHV and RoyVidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top