ms access - How can i get the timestamp and lock the failed login form? -
as title stated, can me form login on access 2013. want timestamp updated on username table (datetype datetime) each successfull login on each userid. problem want lock user login form each 3 times failed login.
private sub cmdlogin_click() if isnull(me.cbonama) or me.cbonama = "" msgbox "please fill username first!", vbokonly, "input username" me.cbonama.setfocus exit sub end if if isnull(me.txtpword) or me.txtpword = "" msgbox "please fill password!", vbokonly, "input password" me.txtpword.setfocus exit sub end if if me.txtpword.value = dlookup("password", "ms_userid", "[password]='" & me.txtpword.value & "'") myuserid = me.cbonama.value msgbox "login success", vbokonly, "message" 'me.last_login = datetime() docmd.close acform, "frm_login", acsaveno docmd.openform "ms_userid" else msgbox "wrong username/password! please specify caps lock, boss..", vbcritical, "error message" me.txtpword.setfocus end if end sub
this latest modification click button vba code, please take since there still error (pop window appears , says "enter parameter value : ms_userid.timestamp" should enter manually ? because i'm using = now() function.
many thanks.!
private sub cmdlogin_click() dim sql string 'check mandatory fields if isnull(me.cbonama.value) or me.cbonama.value = "" msgbox "user id required.", vbokonly, "required data" me.cbonama.setfocus exit sub end if if isnull(me.txtpword.value) or me.txtpword.value = "" msgbox "password required.", vbokonly, "required data" me.txtpword.setfocus exit sub end if sql = "update ms_userid " & _ "set ms_userid.timestamp = now()" & _ "where ms_userid.userid = '&frms!frm_login!cbonama&'" 'compare input password , database password if me.cbonama.value <> "" if me.txtpword.value = dlookup("password", "ms_userid", "[password]='" & me.txtpword.value & "'") 'myuserid = me.cbonama.value 'docmd.runsql "update ms_userid set timestamp = now() userid='" & frms!frm_login!cbonama & "';" docmd.runsql sql 'close login page msgbox "login success", vbokonly, "message" docmd.close acform, "frm_login", acsaveno docmd.openform "ms_userid" else msgbox "invalid password. try again.", vbokonly, "invalid entry!" me.txtpword.setfocus end if end if 'if user enters incorrect password 3 times intloginattempts = intloginattempts + 1 if intloginattempts = 3 msgbox "you not have access database. please contact system administrator.", vbcritical, "restricted access!" application.quit end if end sub
Comments
Post a Comment