473,581 Members | 2,786 Online
Bytes | Software Development & Data Engineering Community
+ 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_E mployee) 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_P ass) 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.Val ue = DLookup("Employ eePassword", "Tbl_Employ ee",
"[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 2460
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 empsecurityleve l
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_E mployee) 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_P ass) 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
1677
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 Subform First subform is a subform of Main Form, and Second Subform is a subform of First Subform.
2
2184
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
1913
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 rooms and the names of who is in those rooms (and how many people are in them) as the detail records. The rooms would be listed vertically, with...
17
4189
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 won't be broken when my app is opened with those versions. Also is the Scripting Runtime included as part of the A2000 Runtime Engine which some of...
55
3516
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 Gunderloy http://www.larkware.com/dg4/TheDailyGrind726.html Aside from the Sharepoint feature extension, amazing news.
35
2536
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 concern since my front-end application will be linked to a SQL SERVER backend. But there seems to be this "conventional wisdom" among IT people...
2
1764
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 the Coding From Access to VB6? e.g The "Add" Command of Access ? On Error GoTo Err_Add_Click
14
3869
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. Having a background in Pascal and some C++, I would have preferred those languages, but VBA made do. The SQL was fine. I believe that Security...
3
1414
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 textbox(txtName) and a button leading to the second form. The second has another textbox(txtFamilyName) and a button both leading to the third form...
0
7882
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7808
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7914
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8181
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6564
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5683
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3835
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2309
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 we have to send another system
1
1410
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.