Passwords fields wont empty

  • Thread starter Thread starter Tourish
  • Start date Start date
T

Tourish

Guest
i want the username and password fields to be empty as the db opens at the moment the they dont clear, i thought the .value ="" on them would clear them but its not working am i missing something else?

Private Sub Login_Click()
On Error GoTo Err_Login_Click

Dim dbCurrent As Database
Dim dbTable As Recordset

Set dbCurrent = DBEngine.Workspaces(0).Databases(0)
Set dbTable = dbCurrent.OpenRecordset("tblPasswords")

Record = 1
Do Until Record = 0

If [UserName] = dbTable![UserName] And [Password] = dbTable![Password] Then
Record = 0

Else
dbTable.MoveNext
End If
Loop
If Record = 0 Then
Dim stDocName As String
Dim stLinkCriteria As String

MsgBox "login successful"
stDocName = "switchboard"
UserName.Value = ""
Password.Value = ""

DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

Exit_Login_Click:
Exit Sub

Err_Login_Click:
MsgBox "User Name or Password incorrect!"
UserName.Value = ""
Password.Value = ""

Resume Exit_Login_Click

End Sub
 
Have U tried:
Username.SetFocus
UserName.Text = ""
Password.SetFocus
Password.Text = ""

Or

UserName.Value = Null
Password.Value = Null
 
Is UserName and Password the names of the text box or the names of the field from the table that the text box is bound too? Not bothI hope. If so, you need to rename your text box by using a decent naming convention like txtUserName and txtPassword.

Then in the OnOpen event of the form you will simply need this...

txtUserName = ""
txtPassword = ""

...to clear the text box when the form is opened.

You do not have to set the focus to a control just to clear it and you do not have to use the .value property when setting the value of the control.

I am not paying attention to the logic of your code since it is hard to read without posting the code in the
Code:
 format but it looks "off".
 

Users who are viewing this thread

Back
Top Bottom