473,396 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I add data to the same row in a table...?

Hello Everyone,
I am totally new to access 2007. I have created a logon form that gets data from a "Employees" table.

I want to add logon date and time information to the same row of a logged on user. If possible add the logout date and time too.

Is it better to create a second table or possible to do everything in one table..?

herewith the logon code used:

----------------------------------
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub cmdLogin_Click()
  4. 'set the variable for the invalid login retry
  5. Static intLogonAttempts As Integer
  6. 'Check to see if data is entered into the UserName combo box
  7.     If IsNull(uname) Or uname = "" Then
  8.       MsgBox "You must choose a User Name.", vbOKOnly, "Required Data"
  9.         uname.SetFocus
  10.         Exit Sub
  11.     End If
  12.  
  13.     'Check to see if data is entered into the password box
  14.  
  15.     If IsNull(passw) Or passw = "" Then
  16.       MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
  17.         passw.SetFocus
  18.         Exit Sub
  19.     End If
  20.  
  21.     'Check value of password in tblEmployees to see if this
  22.     'matches value chosen in combo box
  23. If passw.Value = DLookup("Password", "Employees", _
  24.                                   "[ID]=" & uname.Value) Then
  25.  
  26.     ID = uname.Value
  27.  
  28.     'Close logon form and open Control Panel screen
  29.     'CurrentDb.Execute "INSERT into Employees (LogonDate) VALUES (date())"
  30.     DoCmd.Close acForm, "LogonForm", acSaveNo
  31.     DoCmd.OpenForm "Control Panel"
  32.     intLogonAttempts = 0
  33.  
  34.   Else
  35.       MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
  36.             "Invalid Entry!"
  37.         intLogonAttempts = intLogonAttempts + 1
  38.         passw.SetFocus
  39.  
  40.     End If
  41.  
  42.     'If User Enters incorrect password 3 times database will shutdown
  43.  
  44.  
  45.     If intLogonAttempts > 3 Then
  46.       MsgBox "You do not have access to this database.Please contact admin.", _
  47.                vbCritical, "Restricted Access!"
  48.         Application.Quit
  49.     End If
  50.  
  51. End Sub
  52.  
---------------------------------------
The table is called "Employees"
with fields:
ID - Autonumber
FullName - Text
Password - Text
LogonDate - Date/Time

Thanking you in advance,
Bongazi
Feb 24 '11 #1
2 1481
Mariostg
332 100+
It depends what you want to achieve. If you want to keep a history of a given user logon, you will need a table to keep track of the logon through an insert statement. If you are only interested in the most recent logon, then you could do it in the employee table through an update statement.
Feb 24 '11 #2
Mariostg,

thank you for your quick reply. Could I do both? Keep a logon history in a different table through the insert statement and update the current "Employee" table?
And how would I go about that?

Thank you again for your patience and willingness to share information :-).

Regards,
Bongazi
Feb 24 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Kevin Myers | last post by:
Hello, I'm an experienced application developer in some languages (including various SQL dialects), but have very little experience with MS Access or VBA, and am having trouble figuring out how...
8
by: Woody Splawn | last post by:
Lets say I have a winform that is populated with a dataset. The dataset and data table may have several rows in it. Lets say I am looking at the winform and I want to assign a value to a certain...
2
by: Steve Stover | last post by:
I want to use the caching API in .net to store data. The data would be stored in a data table class that has approx. 10 columns and 71 rows. What I need to know is this: According to Microsoft's...
2
by: Brian Mitchell | last post by:
Ok, I know this is an elementary question but I have a data grid that is bound to a data table and I can't seem to find a way to match the selected row in the grid with it's respective row in the...
1
by: Vasilis X | last post by:
Here is the question : I have a data table, UnShorted, which has a data column EventTime (type : date time) and a data column Values (type : single). I want to create a table, Shorted, that...
1
by: John | last post by:
Hi When using Table Adapter Configuration Wizard if 'Use SQL Statements' is selected as Command Type, the data table's name in dataset is retained and only its data adapter's select statements...
1
by: DH | last post by:
I have an untyped dataset with a table. I am trying to programmatically add a row to this table. This was working in VS 2003 / .net 1.1 I am receiving an error "Object reference not set to an...
1
by: laredotornado | last post by:
Hi, I have a data table on my page (buried amidst other images and extraneous text). I would like to spawn a new window that automatically prints the content of my data table, and only that...
4
by: indona | last post by:
hi, i have to enter data from a delimited file into sqlserver database table. i have been able to delimit the file and read the data into a data table, now i want enter the data table contents to...
1
by: BaseballGraphs | last post by:
Hello, I am trying to divide one value from my data table with an associated ID by another value from my data table with a different ID for the same day that the value was added to the data table....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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,...
0
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...
0
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
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,...

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.