database - code for DLookup for login username and password -


i want make log-in form, don't know how or confirm typed in username , password textbox in table using dlookup in log-in button.

here's current code:

dim u variant dim p variant dim inu string dim inp string  u = dlookup("cusername", "tbl_users", "inuser.value") p = dlookup("cpassword", "tbl_users", "inpass.value")  inu = inuser.value inp = inpass.value  if inu = u , inp = p docmd.openform "frm_userlog" msgbox "welcome " & tuser & "!"  elseif isnull(me.inuser.value) , inpass.value = 1 msgbox "you must input username"  elseif isnull(me.inpass.value) , inuser.value = 1 msgbox "you must input password"  elseif isnull(me.inuser.value) , isnull(me.inpass.value) msgbox "you must input username , password"  else msgbox "the username or password entered invalid"     end if end sub 

the third dlookup argument, criteria, optional string expression similar "where clause in sql expression, without word where".

in yours, seem trying give value of control named inuser. you're passing string contains text "inuser.value".

dlookup("cusername", "tbl_users", "inuser.value") 

but won't give want if remove quotes.

if want cusername tbl_users field (perhaps user_id) matches inuser.value ...

dlookup("cusername", "tbl_users", "user_id = " & inuser.value) 

if field, user_id, text rather numeric data type, build quotes criteria string ...

dlookup("cusername", "tbl_users", "user_id = '" & inuser.value & "'") 

it looks me have same type of issue dlookup("cpassword", ...), if got first 1 right, make similar change there.

you can find more information dlookup @ description of dlookup() usage, examples, , troubleshooting in access 2000. although that's old article, still applies recent access versions afaict.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -