473,473 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Microsoft Access VBA Coding Question - Log In Form

Hi there,
I would be very greatful if somebody could help me with my trouble
using VBA to code a button on a form. Basically what i want to happen
is on the click of the button i want it to validate the data entered
into the username and password fields stored in a table. This is not
the problem, the problem is getting it to open a different form for a
manager or for a member of staff dependant on the access level stored
in the same table as the pass and username.
Below i show my coding behind the button.

Private Sub Btn_Login_Click()

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

If IsNull(Me.Cbo_Employee) Or Me.Cbo_Employee = "" Then
MsgBox "Please select your User Name."
Exit Sub
End If

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

If IsNull(Me.Txt_Pass) Or Me.Txt_Pass = "" Then
MsgBox "Please enter your Password."
Exit Sub
End If

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

If Me.Txt_Pass.Value = DLookup("EmployeePassword", "Tbl_Employee",
"[EmployeeNumber]=" & Me.Cbo_Employee.Value) Then

EmployeeNumber = Me.Cbo_Employee.Value

'Close logon form and open splash screen
DoCmd.OpenForm "Frm_Menu Managers"

Else
MsgBox "Log In Details Incorrect. Please Try Again", vbInformation
End If

End Sub
Email any help as this would be much appreciated. thanks in advance
Mike

Feb 15 '07 #1
1 2446
A suggestion:

Since all of the info you require is in the employee table,

1) Base the combo box on a query that gets the following fields in the
following order
empusername emppassword empsecuritylevel
2) have
bound field on combo be field 1
Number of fields is 3
field lengths is 1";0";0"

3) button routine is now

Private Sub Btn_Login_Click()

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

If IsNull(Me.Cbo_Employee) Or Me.Cbo_Employee = "" Then
MsgBox "Please select your User Name."
Exit Sub
End If

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

If IsNull(Me.Txt_Pass) Or Me.Txt_Pass = "" Then
MsgBox "Please enter your Password."
Exit Sub
End If

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

if not me.cbo_Employee.column(1) = me.txt_Pass then
MsgBox "Either the Password is incorrect or you selected
the wrong name."
Exit Sub
End If

if Me.Cbo_Employee(2) = "Manager" then ' or whatever
test to say it is manager
DoCmd.OpenForm "Frm_Menu Managers"
else
DoCmd.OpenForm "Frm_Menu for NON Managers"

end if

End Sub
=========================

The column count in combo boxes is relative to 0 - First field is
column 0 etc.

Ron


Feb 15 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Julia Baresch | last post by:
Hi everyone, My company recently upgraded from Office 97 to Office XP. As those who've read my other posts know I have a database with 3 nested subforms Main form-->First Subform-->Second...
2
by: Alicia | last post by:
If I wanted to create a table by hand create table temp( etc, where do I do it in access?
7
by: pw | last post by:
Hi, We need a Gantt chart type calendar for Access 97 (and soon, Access 2003). We need it to list the days of the month (for a date range) going horizontally across the top, the names of the...
17
by: Karl Irvin | last post by:
To use the Textstream object, I had to set a Reference to the Microsoft Scripting Runtime. This works good with A2000 Is the Scripting Runtime included with A2002 and A2003 so the Reference...
55
by: AnandaSim | last post by:
I just had a google through this NG but have not seen mention of Erik Rucker's blog entry and the new Jet: http://blogs.msdn.com/access/archive/2005/10/05/477549.aspx mentioned by Mike...
35
by: robert d via AccessMonster.com | last post by:
I was asked to provide a proposal. I provided a proposal on my application and the prospective client likes what I have but is wary of it having been developed in Access. I don't understand this...
2
by: OldSchool | last post by:
Guys, Thanks for the Reply i recieved from one of our Buddy here in Community. Question REgarding Coding of VB6 and Access 1. Are they same when it comes to Coding? 2. Can i Copy and Paste...
14
by: ApexData | last post by:
I am considering building some distributable commercial applications. For about a year now, I have been using Access2000. This was my first venture into object oriented database development. ...
3
by: Zabooster | last post by:
I have a project to submit in a few hours' time. In order to explain what I need clearly, I will provide a very simple example. Suppose I have an application consisting of 3 forms- The first has a...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.