Solved

How block entry to form if password field is blank

Posted on 2014-04-09
2
299 Views
Last Modified: 2014-04-09
I have this code in an onclick event of a command button on a form but it allows the user to just proceed with nothing in the password field.

What is wrong with this?

If Me.txtPassword <> DLookup("[MaintPassword]", "tblSetup") Or Me.txtPassword = "" Then
        MsgBox "You do not have permission to use any of the database maintenance functions."

--Steve
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
COACHMAN99 earned 500 total points
ID: 39989382
try
If NZ(Me.txtPassword,"")  <> DLookup("[MaintPassword]", "tblSetup")   Or Me.txtPassword ="" then
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39989412
If  Nz(DLookup("MaintPassword", "tblSetup", "MaintPassword ='" & Me.txtPassword & "'"),"")="" Or Me.txtPassword = "" Then

MsgBox "You do not have permission to use any of the database maintenance functions."

exit sub
else


end if

Open in new window



or
If Me.txtPassword & "" = "" Then
    Exit Sub
end if

If  Nz(DLookup("MaintPassword", "tblSetup", "MaintPassword ='" & Me.txtPassword & "'"),"")=""  Then

MsgBox "You do not have permission to use any of the database maintenance functions."

exit sub
else


end if

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question