...

View Full Version : Visual Basic Help



axd
02-28-2013, 11:23 AM
Hi, i don't know if I have the correct forum, so please be kind if I don't, and just point me in the right direction. This question will cover a bit of VBA and SQL. SQL I am familiar with, Visual Basic I am not, but here is my issue.

I am follow a coding example for a login system for Microsoft Access. It all seems straight forward, the code checks whats been entered into the login box, and password box, then checks it against a table of existing users. If it finds the match then access is granted to the database/application.

I wish to edit the code slightly so that the application also enters the users details into another table once he/she logs in, therefore creating a "logged in session status", that I can apply when the user logs in, and truncate out when they log off.

The bit of coding I need is solely to enter whatever was entered into the username/password box upon successful authentication/login. Here is the code template I am using.

Thanks to anybody with the necessary skillset to help me, in advance!



Private Sub cmdLogin_Click()

Dim dbs As DAO.Database
Dim rstUserPwd As Recordset
Dim bFoundWatch As Boolean

Set dbs = CurrentDb

Set rstUserPwd = dbs.OpenRecordset("qryUserPwd")

bFoundMatch = False

If rstUserPwd.RecordCount > 0 Then
rstUserPwd.MoveFirst

'Check for matching records

Do While rstUserPwd.EOF = False
If rstUserPwd![UserName] = Form_frmLogin.txtUsername.Value And rstUserPwd![Password] = Form_frmLogin.txtpassword.Value Then
bFoundMatch = True
Exit Do

End If
rstUserPwd.MoveNext
Loop

End If

If bFoundMatch = True Then
'Open the next form here and close this one
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "frmNavigation"

Else
'
MsgBox "Incorrect Username or Password"

End If


End Sub

bbarrick
03-04-2013, 10:22 PM
You want to record their username and password?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum