Solved

How block entry to form if password field is blank

Posted on 2014-04-09
2
300 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

624 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