Hi,
I am building a Staff holiday database and I would like to have the user login and when the user books the holiday the table detects who is logged in and auto create a record entry and time of the user.
How do I do this?
Hi,
I am building a Staff holiday database and I would like to have the user login and when the user books the holiday the table detects who is logged in and auto create a record entry and time of the user.
How do I do this?
does your database have login method you designed? i.e. each person has a login and password stored in a table in your database that you're using to validate the user?
If so on a successful login you can do something like:
1. Create a table tblLoginAttempts, put two fields on the table, USERID (assuming you're using an autonumber as a primary key for your user table) and DATEADDED set the default value of the DATEADDED field to now()
2. if you just want to store successful attempts to log in add to your 'successful' part of code
the DATEADDED field will be automatically populated with the date/time the person's ID was added to the table.Code:dim db as database dim iUserID as long set db = currentdb iUserID = dlookup("[UserID]", "tblLogins", "[UserName] = " & username) db.execute ("INSERT INTO tblLoginAttempts (UserID) VALUES (" & iuserid & ")") set db = nothing
This assumes your USER table is named tblLogins
Your table tblLogins has an autonumber primary key and the USERNAME is unique
Thanks for the quick reply and help!
Here is my layout
Front startup screen
Successful login
is there a follow up question? The only thing different is that you are allowing the users to select their name so instead of having to use dlookup to find their employee ID you can just adopt the value of the combo box assuming you are using an autonumber as the primary key of the table and it is also the bound column of your combo box.
Button macro 1 pt1
Button macro pt2
Users table
Thanks again for the help [emoji4]
I don't use macros so I can't help you there but you are checking a dlookup value in the get userID section, that's where you'd want to append a record to a table but I have no idea how you'd do that in a macro or if it's even possible unless you had an append query written using the same methodology I described above, then just run the query on a successful login.
Many thanks again.
Don't know enough about VBA yet or to make a query or how to add to the existing macro but I get your logic.
Any tips or Web links to a code I could copy or tutorials.
If need be I can scrap my login firm and start a fresh and create tables to match the code
if you look at where you force a message box with the 'password correct', you can add another condition there and run your append query in the macro I would think.