1,105,208 Community Members

code for login and password..using vb6

Member Avatar
stackOverflow
Junior Poster
116 posts since Dec 2004
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-6
 

Hi,

Front end Vb6, back end.. access... connection.. ODADB... can someone please help me with the code for login and password.

Member Avatar
Comatose
Taboo Programmer
2,536 posts since Dec 2004
Reputation Points: 290 [?]
Q&As Helped to Solve: 227 [?]
Skill Endorsements: 34 [?]
Team Colleague
 
3
 

so, the usernames and passwords are stored in an access database?

Member Avatar
stackOverflow
Junior Poster
116 posts since Dec 2004
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

so, the usernames and passwords are stored in an access database?

yes...they are stored in access

Member Avatar
Kiba Ookami
Junior Poster in Training
66 posts since Jan 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
-2
 

Ummm I'm probobly no help...but part of the thing could be done...

IF strUserName="____" AND strPassoword="________" THEN
What happens when you do that
ELSE
It dosn't
END IF

Member Avatar
Comatose
Taboo Programmer
2,536 posts since Dec 2004
Reputation Points: 290 [?]
Q&As Helped to Solve: 227 [?]
Skill Endorsements: 34 [?]
Team Colleague
 
-2
 

how does the access table look, and what are the field names?

Member Avatar
NewVBguy
Junior Poster in Training
71 posts since Mar 2005
Reputation Points: 3 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
1
 

Hi,

Front end Vb6, back end.. access... connection.. ODADB... can someone please help me with the code for login and password.

Hi,

just to give some inputs:

in your form you need to have 2 txt field:
1. txtlogin
2: txtpwd

then:

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"
        Else
            MsgBox "Wrong password or Login not found."
        End If
    Else
        MsgBox "Login and password should not be blank"
    End If
End If
End Sub

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"
    Else
        ret = "wrong"
    End If
Else
    ret = "wrong"
End If
rs.Close: CheckPwd = ret
End Function

'This is just to give you an idea. For sure there are lot of ways of doing it...


Newvbguy

Member Avatar
naiJenn
Newbie Poster
1 post since Nov 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Differences:

  • 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
        txtUser.SetFocus
        Exit Sub
    End If
    
    'check for null password
    If IsNull(Trim(txtPassword)) Then
        MsgBox "Password required.", vbExclamation
        txtPassword.SetFocus
        Exit Sub
    End If
    
    '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")))
    End If
    
    'close the recordset and release the recordset object variable
    tempRecordSet.Close
    Set tempRecordSet = Nothing
    
    'check the password
    If Password <> UCase(Trim(txtPassword)) Then
       MsgBox "Incorrect password", vbExclamation
    Else
        'passwords match, allow the user to the maintenance switchboard
        MsgBox "Congratulations! Right Password!!!", vbExclamation
    End If
    txtPassword = Empty
End Sub
Member Avatar
Ancient Dragon
Achieved Level 70
27,596 posts since Aug 2005
Reputation Points: 5,232 [?]
Q&As Helped to Solve: 3,032 [?]
Skill Endorsements: 115 [?]
Team Colleague
Featured
Sponsor
 
0
 

please don't resurrect two year old threads. Thread closed.

Member Avatar
jsirmugo
Newbie Poster
2 posts since Oct 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 
private sub command1_()
adodc1.recordset.addnew
end sub
Member Avatar
jsirmugo
Newbie Poster
2 posts since Oct 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Private Sub CMDLOGIN_Click()
cn.Open GetConnString

rs.Open "Select * from SYSTEMUSERS where UserName='" & txtusername.Text & "' AND Passwords='" & Txtpasword.Text & "'", cn, adOpenKeyset, adLockOptimistic

If rs.RecordCount >= 1 And rs!isactive = True Then
LoginSuccess = True
MsgBox "CONGRATULATION!RIGHT PASSWORD!!!", vbExclamation

        Select Case rs!usergroup

        Case 1

        Case 2
            MDIForm1.MNUEDITFORM.Visible = False
        Case 3
            MDIForm1.MNUEDITFORM.Visible = False
        Case Else

        End Select

Unload Me

Else

     MsgBox "Try Again"

End If

End Sub

Rutembesa Bruce
Newbie Poster
1 post since Dec 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

bruce
i hve maked a login form but when i click on a cmd buttom nothing is displayed.

private sub Cmdlogin_Click

if Txt1.text="admin" and Txt2.text="admin" then
MDIForm.show
else
Txt1.text=""
Txt2.text=""

end if

end sub

Member Avatar
Jx_Man
Senior Poster
3,543 posts since Nov 2007
Reputation Points: 987 [?]
Q&As Helped to Solve: 542 [?]
Skill Endorsements: 74 [?]
Featured
 
0
 
goldcutezz
Newbie Poster
1 post since Feb 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
1
 

what is the code for log in that when you put the password it is already in an asterisk form ..
thnak you

Member Avatar
Triyansha
Newbie Poster
1 post since Dec 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

aryasbhat
Newbie Poster
1 post since Jan 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

HI i just want an login page code for my library mangement project front end is vb6.0 and back end is access( i dont know wat is front end and back end just iam using both)

You
Post:
Start New Discussion
Tags Related to this Article