Setting a value

KeaganQuilty

Registered User.
Local time
Today, 17:44
Joined
Jun 28, 2001
Messages
51
Here Goes,

For security purposes, I have a login screen in which users type in their names and passwords. The names and passwords are stored in a table, along with the date of their last login and the date they last changed their password.

Question... How do I set a new value for the password, last login date, and so forth, in VB code?

i.e. I want the lastOn date to change each time the user logs in. The table is not listed in the control source of the form. I currently use the DLookup function to confirm that the user exists and that the password is valid.

Please help. Thank You

Keagan Quilty
Kilbride, Newfoundland
 
You can run an update query after validation...

dim MyDB as database
dim MySQL as string

MySQL = "UPDATE [UserTable] SET lastOn=#" & date() & "#, Password='" & NewPassword & "', PasswordDate=#" & date() & "# Where UserName='" & UserEnteredName & "'"

Set MyDB = currentdb
MyDB.Execute MySQL

MyDB.close
Set MyDB = nothing

This will update your table to hold current date... To add additional fields to update, just seperate with commas, like above. Hope this helps.

Doug
 
That gives me an error

Run Time Error '3601'

Too few expected parameters. Expected 1.

When I hit Debug, It highlights this line...


mydb.execute MySQL

I'm not quite sure of how to fix this. I put () around MySQL, and the only other parameters listed in the popup were optional.

Keagan Quilty
Kilbride, Newfoundland
 
Check your SQL statement. I guarantee that is what is generating the error.
 

Users who are viewing this thread

Back
Top Bottom