Ms Access Login form and User Level

Anonymous
2021-04-17T02:19:13+00:00

I am trying to make Login Form Using DCount and LookUp functions 

My table has the following field LoginID, UserName, Password, Level and Description

Form has:

Combobox Named: "txtUser" bound column is 1 (LoginID) and I hide it by sitting Column Widths by 0

TextBox Named "txtPass"

Login Button and I use If function with AND but it does not work, access alway open the main form to me he did not use "else"

  1. I want to say If txtUser and txtPass Mach then, show me message said Successfully, Close Login Form, Open the Main Form, else show me message said Failed, but access does not match "AND" he always open the Main form even If I put wrong password

If

I did this DCount("LoginID","LoginT","UserName=[txtUser]" And "Password=[txtPass]")

I did this DCount("LoginID","LoginT","UserNamer=[txtPass]") And ("Password","LoginT","Password=[txtPass]")

I did this DCount("LoginID","LoginT","UserNamer=[txtPass]" And "Password","LoginT","Password=[txtPass]")

I did this DCount("Password","LoginT","Password=[txtPass]")

they did not work

  1. How can I add Level deal with Levels by LookUp?

if the txtUser and txtPass Mach and his Level is 1 as admin open the Main form as edit, else as Read only

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

17 answers

Sort by: Most helpful
  1. Tom van Stiphout 40,091 Reputation points MVP Volunteer Moderator
    2021-04-17T17:58:59+00:00

    Can you see the problem?

    No double-quote after the username. Add it, using the same syntax as already shown to you.

    0 comments No comments
  2. Anonymous
    2021-04-17T18:04:58+00:00

    Can you see the problem?

    No double-quote after the username. Add it, using the same syntax as already shown to you.

    I did I past the same code in Macro, I got same problem that I post it before

     DCount("LoginID","LoginT","[UserName]=""" & [txtUser] & " AND [Password]=""" & [txtPass] & """")

    plz help
    Image

    0 comments No comments
  3. Anonymous
    2021-04-17T19:58:38+00:00

    Try

    DCount("LoginID","LoginT","[UserName]='" & [txtUser] & "' AND [Password]='" & [txtPass] & "'")

    0 comments No comments
  4. Anonymous
    2021-04-17T20:12:06+00:00

    Now if Chose User 1 and his password I got this message box, it did not pass throw 

    0 comments No comments
  5. Anonymous
    2021-04-18T00:10:04+00:00

    I see you should want to build a multi-user application because of needing a login form.

    According to the restrict of VBA and depends on macro,it looks not flexible and uneasy.

    So , if possible,web architecture( like asp+mdb ) is not a bad choice.

    0 comments No comments