Log In help- Begginner

  • Thread starter Thread starter seanom
  • Start date Start date
S

seanom

Guest
Hi I am trying to create a database that users can log into. I have created a form with a combo box which allows users to select there user name and then an input field for the password.

I can create the SQL i think to check the data entered against that in the database but do not know the syntax to use to code this in vb with the code builder.

I think I need to create to strings to store the values in and then I check these variables against the password field to make sure they are the same but really have no idea what sort of syntax to use.

Any help would be most appreciated (or alternative solutions)(or being pointed to any good tutorials that explain this)
Thank you in advance
Sean
 
Sean,

similar questions have been asked quite often on the forum.
Use the search facilty.

Regards,

RV
 
Apologies I did try a search before posting but did not find any relevant posts its may have just been the search terms i used though.

/regards
 
Solution?

Hi,

here is some code that I have been using before, and it works fine for me.

tblUser
pkeyID
strUserName
strUserID
strPW

frmLogIn
Use this code for your LogIn button:

Private Sub cmdLog_In_Click()
Dim intLogonAttempts As Integer

If IsNull(cboUserID) = True Then
MsgBox "Please select user name from drop down.", vbOKOnly, "Invalid User!"
Me.cboUserID.SetFocus
End If

If IsNull(txtPW) = True Then
MsgBox "Please enter correct password.", vbOKOnly, "Invalid Password!"
Me.txtPW.SetFocus
End If

If Me.txtPW.Value = DLookup("strPw", "tblUser", "[pkeyID] =" & Me.cboUserID.Value) Then
cboUserID = Me.cboUserID.Value
DoCmd.Close acForm, "frmPass", acSaveNo
DoCmd.OpenForm "frmPerson"
Else
MsgBox "Password Invalid. Please Try Again.", vbOKOnly, "Invalid Entry!"
Me.txtPW.SetFocus
End If

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 2 Then
MsgBox "You do not have access to this database. Please contact database administrator!"
DoCmd.Close
End If
End Sub

Any questions?

Best regardz,
Spikemannen
 

Users who are viewing this thread

Back
Top Bottom