Filter Based on Log On

B

Beatrix J B

Hi.. I was able to make a log in screen with corresponding codes ......

I also included (if right) lnguserno = me.combo0.value .... which is suppose
to store publicly? the userno. .... How do i make use of this value to be
filter criteria for all other forms that would be opened. I want all the
succeeding forms be filtered based on the lnguserno variable.

Is there any example on this that I can refer to?

Thanks. Hoping for your fast response.


Option Compare Database
Option Explicit
Dim lnguserno As String
Dim intlogonattempts As Integer

Private Sub Combo0_AfterUpdate()
Me.txtPassword.SetFocus
End Sub

Private Sub Command5_Click()

'Check to see if data is entered into the Username Combobox
If IsNull(Me.Combo0.Value) Or Me.Combo0.Value = "" Then
MsgBox "Please choose User Log-In from ComboBox List.", vbOKOnly,
"Required Data"
Me.Combo0.SetFocus
Exit Sub
End If

'Check to see if data is entered into the Password Box
If IsNull(Me.txtPassword.Value) Or Me.txtPassword.Value = "" Then
MsgBox "Please enter your Password.", vbOKOnly, "Required"
Me.txtPassword.SetFocus
Exit Sub
End If

'check value of password into tblUSERS to see if it matches value

If Me.txtPassword.Value = DLookup("PASSWORD", "tblUSERS", "[USERNO]=
Forms![frmAUTHENTICATION]![Combo0]") Then

lnguserno = Me.Combo0.Value

'close log-on form and open splash screen

DoCmd.Close acForm, "frmAUTHENTICATION", acSaveNo

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If

'if user enters incorrect password 3 times database will shutdown

intlogonattempts = intlogonattempts + 1
If intlogonattempts > 2 Then
MsgBox "You do not have access to this application. Please contact your
administrator.", vbCritical, "Restricted Access"
Application.Quit
Exit Sub
End If

End Sub

Private Sub Command6_Click()

Dim vbmsgresult As Integer
vbmsgresult = MsgBox("Would you really like to quit this application?",
vbYesNo + vbQuestion, "Quit Application?")

If vbmsgresult = vbYes Then
Application.Quit
End If

End Sub

Private Sub Form_Load()
If IsNull(DLookup("coname", "tblcompany")) Then
Me.Caption = "No Company Data"
Else
Me.Caption = DLookup("coname", "tblcompany")
End If
End Sub
 
D

david epsom dot com dot au

Put the value in a table, and join the table to all
the queryies.

Bind the forms to the queries instead of binding directly
to the tables.

Much easier and works better than using a filter on everything.

And you can still easily use the filter for something else
without worrying about this.

(david)
 

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