473,779 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VBA Code learner Please Help

Hi all I can write basic VBA code.
I have on problem, I have a tbl with the following fields:
lngempID - Name - Password - IN

This is for a logon form once the user logon I want the field IN to
mark the current users as logedon (true)

I need to open recordsets, that I know but have tried everything.
Please Help me!!!!!

On the Main MDIFORM I need a button to log user off and change the IN
status to false.

South Africa
Nov 12 '05 #1
1 1442
First things first, don't use "Name" as a field name, in your case change it
to "EmployeeNa me". Name is a reserved word in Access and it can cause you
grief later on. Also change the "IN" field to "LoggedIn"

In the logon form use a combo box that lists the users' names so the user
can then select their name instead on typing it. Use 2 columns in the combo
box: lngEmpID, EmployeeName. Set the combo box's column count to 2 and the
column width to 0cm;3.5cm. This will hide the first column and display the
second. Also make sure there is a text box for the user to type in the
password.

Behind the button you're going to use to log the user in copy the following
code.
(I'm using "tbl" as the table name, change this to the actual name of the
table)

' **************C ODE START 1 *************** **********
Dim db as DAO.Database
Dim rst as DAO.Recordset
Dim strSQL as String

On Error GoTo LogInErr

strSQL = "SELECT lngEmplD, Password, LoggedIn " _
& "FROM tbl " _
& "WHERE lngEmpID = " & Me!ComboBoxName & ";"

Set db = CurrentDB
Set rst = db.OpenRecordse t(strSQL)

With rst
If .RecordCount = 0 Then
MsgBox "Please select a user"
Else
If !Password <> Me!PasswordText BoxName Then
MsgBox "Incorrect password", vbCritical
Else
If !LoggedIn = True Then
MsgBox "This user is already logged in"
Else
!LoggedIn = True
End If
End If
End If
End With

LogInExit:
On Error Resume Next
rst.Close
Set rst = Nothing
Set db = Nothing
Exit Sub

LogInErr:
MsgBox "Error # " & Err.Number & " has occured." & vbcrlf _
& vbcrlf & Err.Description
Resume LogInExit
'************** *CODE END 1************** *************** ******

To log the person off place the following code behind the Log Off button.

'************** CODE START 2 *************** *************** ***
Dim db as DAO.Database
Dim rst as DAO.RecordSet
Dim strSQL as String

On Error GoTo LogOutErr

strSQL = "SELECT lngEmplD, LoggedIn " _
& "FROM tbl " _
& "WHERE lngEmpID = " & Me!ComboBoxName & ";"

Set db = CurrentDB
Set rst = db.OpenRecordse t(strSQL)

With rst
If .RecordCount = 0 Then
MsgBox "This user doesn't exist or is not logged in."
Else
!LoggedIn = False
MsgBox "User successfully logged out."
End If
End With

LogOutExit:
On Error Resume Next
rst.Close
Set rst = Nothing
Set db = Nothing
Exit Sub

LogOutErr:
MsgBox "Error # " & Err.Number & " has occured." & vbcrlf _
& vbcrlf & Err.Description
Resume LogOutExit
'************** *******CODE END 2 *************** *************** *****

"Mark" <te********@web mail.co.za> wrote in message
news:40******** *************** ***@posting.goo gle.com...
Hi all I can write basic VBA code.
I have on problem, I have a tbl with the following fields:
lngempID - Name - Password - IN

This is for a logon form once the user logon I want the field IN to
mark the current users as logedon (true)

I need to open recordsets, that I know but have tried everything.
Please Help me!!!!!

On the Main MDIFORM I need a button to log user off and change the IN
status to false.

South Africa

Nov 12 '05 #2

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

Similar topics

242
13459
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any comments on past experience, research articles, comments on the matter would be much appreciated. I suspect something like C would be the best based on comments I received from the VB news group. Thanks for the help in advance James Cameron
8
1461
by: ilPostino | last post by:
This question is for long term coders hense the extra posting on c# ;) I find coding for long periods and on big projects frustrating when trying to use keyboard AND mouse. Do any of you use just plain text editors besides VS? Is it possible to use VS without a mouse, I've tried but it ain't easy ;) or am I just mouse-phobic! there is a huge time delay switching keyboard/mouse all the time.
22
2176
by: larry | last post by:
I was just looking at a demo training that mindleaders has on .net training: http://www.mindleaders.com/products/democourse3.asp And I don't believe this is correct or at least is misleading to me: "The search for an easy, productive, and very powerful programming language led to the birth of Visual C#. Visual C# incorporates the best features of Visual C++ and Visual Basic. Visual C# enables you to
6
1497
by: C# Learner | last post by:
In the following two code blocks, DoSomethingUseful throws AnException, while neither of the other called methods throw any exceptions. Which of the code blocks is better (in terms of readability, maintainability, etc.), in your opinions? A { Start(); try {
239
10323
by: Eigenvector | last post by:
My question is more generic, but it involves what I consider ANSI standard C and portability. I happen to be a system admin for multiple platforms and as such a lot of the applications that my users request are a part of the OpenSource community. Many if not most of those applications strongly require the presence of the GNU compiling suite to work properly. My assumption is that this is due to the author/s creating the applications...
5
2161
by: | last post by:
Hello, I am wrtting a program that does some sound effects... the files are stored in a subfolder in the application folder... and I check the existence of the files before calling the method to play the sound. It works perfectly well in Windows XP, but when I move my application to a Vista machine, the sound does not play... I used a debug statement to confirm that the files are seen in the code but somehow it does not play... If I use...
1
1074
by: bill.wu | last post by:
in this list: mail.python.org Mailing Lists. which one suits for learner. thanks very much.
2
1691
by: 2pot | last post by:
Someone willing to help an ambitious noob learner fix his program? I'll PM to whoever says yes.
18
2510
by: subramanian100in | last post by:
Consider a class that has vector< pair<int, string>* c; as member data object. I need to use operator>to store values into this container object and operator<< to print the contents of the container. I have written both these operators as non-friend functions.
0
9636
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10139
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10075
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9931
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8961
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5373
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3632
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.