Enable Buttons on Login Form

D

Downie

users Table has
id
username
password
role

The Enters username password on Login form and clicks the Login Button
(Command53)

Private Sub Command53_Click()
Dim cnn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rst As New ADODB.Recordset

Set cnn = CurrentProject.Connection
Set cmd.ActiveConnection = cnn

SQLString = "SELECT users.username, users.role FROM [users] WHERE
(((users.username) = " & """" & Login.Value & """" & ") AND
((users.password) = " & """" & Password.Value & """" & "));"
' MsgBox (SQLString)
cmd.CommandText = SQLString
rst.CursorLocation = adUseClient
rst.Open cmd, , adOpenKeyset, adLockOptimistic
MsgBox (rst.GetString)
If rst.RecordCount > 0 Then
DoCmd.OpenForm "MAIN"

Else
MsgBox ("Invalid Username / Password")
End If

End Sub

There are 4 buttons on the MAIN Form.
Based on what the user login "role" is enabls certain buttons.

Any suggestions??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top