After Update procedure

ubgu3

Registered User.
Local time
Tomorrow, 10:41
Joined
Nov 21, 2006
Messages
13
Greeting wise one...

I have implemented a logon script found in this forum - many thanks.
In essance, the script opens a form with info based on a table.
Could I filter the records of the form by only only including those records that are associated with the UserID of the user that just logged on?

The script:
Private Sub cmdLogin_Click()

'Check to see if data is entered into the UserName combo box

If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee.SetFocus
Exit Sub
End If

'Check to see if data is entered into the password box

If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If

'Check value of password in tblEmployees to see if this
'matches value chosen in combo box

If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", _
"[lngEmpID]=" & Me.cboEmployee.Value) Then


lngEmpID = Me.cboEmployee.Value

'Close logon form and open splash screen

DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "frmMain"
Perhapt a filter here?????


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 > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", _
vbCritical, "Restricted Access!"
Application.Quit
End If

End Sub
 
In VBA Help for OpenForm, look at the wherecondition argument.
 
Cheers, I understand a little more.

DoCmd.OpenForm "frmMain", , , ingUserID = Me.cboEmployee
DoCmd.Close acForm, "frmLogon", acSaveNo

This seems to open the form without any data?
How do you express this:
Where records in the tblClients - ingUserID = ingUserID in Me.cboEmployee
in the SQL wherecondition statement?

I appreciate your help!
 
From Help, the wherecondition is:

A string expression that's a valid SQL WHERE clause without the word WHERE.

and there are samples. In your case, presuming that's a numeric field:

DoCmd.OpenForm "frmMain", , , "ingUserID = " & Me.cboEmployee
 
Mmmm. That didn't do it for me.
Could you have a look and tell me where it is going wrong?
 

Attachments

That appears to be an empty zip file.
 
is your employee code a text or a number - this wil make a difference - in the logon you are treating it as text, but in your where filter for the form you are treating it as numeric, so this will rpobably be the cause of your error

as Paul says, this works for numeric only

DoCmd.OpenForm "frmMain", , , "ingUserID = " & Me.cboEmployee

if its text it needs to be

DoCmd.OpenForm "frmMain", , , "ingUserID = " & chr(34) & Me.cboEmployee & chr(34)
 
To my tutors - I have it working - my hat off to you both.
 

Users who are viewing this thread

Back
Top Bottom