Front end Vb6, back end.. access... connection.. ODADB... can someone please help me with the code for login and password.
just to give some inputs:
in your form you need to have 2 txt field:
Private Sub txtpwd_KeyPress(KeyAscii As Integer)
If KeyAscii = vbEnter Then
If Len(Trim(txtlogin)) > 0 And Len(Trim(txtpwd)) > 0 Then
If CheckPwd(txtlogin, txtpwd) = "ok" Then
MsgBox "Password ok"
MsgBox "Wrong password or Login not found."
MsgBox "Login and password should not be blank"
Private Function CheckPwd(cLogin As String, cPwd As String)
'in my case i will use dao. you probably using ado just convert it
Dim rs As Recordset, ret As String
Set rs = opendatabase("c:\temp\login.mdb").openrecordset("select * from tbllogin where ucase(trim(logname)) = '" & UCase(Trim(cLogin)) & "'")
If rs.RecordCount <> 0 Then
If UCase(Trim(rs("pword"))) = UCase(Trim(cPwd)) Then
ret = "ok"
ret = "wrong"
ret = "wrong"
rs.Close: CheckPwd = ret
'This is just to give you an idea. For sure there are lot of ways of doing it...
Just wanted to thank you for the code - This was incredibly helpful.
I set up a similar situation and thought I'd share my code.
I have not included a keyPress Sub but did it from a button click instead.
I call from the current database instead of a different one.
The recordset is exited as soon as possible, and then any conditions not concerning the recordset are administered.
I could have used a function, but this was a quickie. Most likely will update this to include keypress as well as button click in which both subs call a function.
The table accessed (AdminUser) contains a primary key called 'UserID' [text] and a 'Password' field.
My txtBoxes are named txtUser, and txtPassword
Lots of comments - hope it helps anyone.
Private Sub cmdMaintenanceSwitchboard_Click()
'check for null password
If IsNull(Trim(txtUser)) Then
MsgBox "User Name required.", vbExclamation
'check for null password
If IsNull(Trim(txtPassword)) Then
MsgBox "Password required.", vbExclamation
'To use the following code, open the code window for a form.
'Under the Tools/References menu, enable the "Microsoft DAO 3.6 Object Library"
'and some may have to disable the "Microsoft ActiveX Data Objects Library"
'declare variables (tempRecordSet becomes an object variable)
Dim tempRecordSet As Recordset, Password As String
'open the AdminUsers table
'(recordset object variables allow access to records and fields in tables and queries.
'This modified version opens a recordset via a SQL statement to pull the record (if any) where the field matches the txtUser field in the form.
'Since the field is a primary key, there should only be one record if any matches are found.
Set tempRecordSet = CurrentDb.OpenRecordset("select * from AdminUsers where UCase(trim(UserID)) = '" & UCase(Trim(txtUser)) & "'")
'retrieve the Password field from the AdminUsers table if the UserID matches the txtUser Field
If tempRecordSet.RecordCount <> 0 Then
Password = UCase(Trim(tempRecordSet("Password")))
'close the recordset and release the recordset object variable
Set tempRecordSet = Nothing
'check the password
If Password <> UCase(Trim(txtPassword)) Then
MsgBox "Incorrect password", vbExclamation
'passwords match, allow the user to the maintenance switchboard
MsgBox "Congratulations! Right Password!!!", vbExclamation
txtPassword = Empty
for that you can click on the text box in which the user will enter the password, and in the little properties table on the side there is a box that says "passwordcharacter". You will see that the box next to it is empty so put an asterick in it. Then you will see that any text in the text box will be written in astericks including the caption of the textbox. There will be one astericks for each letter.
I Developed application in C# with crystal reports and created setup file in third party (Advance) Installer.When i installed my application on client system application is working but ...