View Full Version : Setting a value


KeaganQuilty
07-26-2001, 05:21 AM
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

D-Fresh
07-26-2001, 05:58 AM
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

KeaganQuilty
07-26-2001, 06:20 AM
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

charityg
07-26-2001, 07:47 AM
Check your SQL statement. I guarantee that is what is generating the error.