Code to check for blank field

  • Thread starter Thread starter google3luo359
  • Start date Start date
G

google3luo359

Hello, I have a set-password form working quite nicely.
I need to make one adjustment however and could use a bit of help.

Each user initially will have a blank in their password field (main
table). They will have the option of not using a password to work on a
data entry form or to use a set-password form to choose their own
password.

The set-password form is set up to check for various errors such as not
filling in the new password, or the re-typed new password, or leaving
the old password field blank.

This works fine for when passwords have been set and a change is
desired.
But for the first time, when there is a blank in the main table's
password field, the 'old password' error-checking will not allow the
user to set a password because it will return an error saying "please
enter Old Password".

So I need code/query to check if the password field in the main table
is blank, and if it is, to skip the 'old password' error-checking part
of the VB code.

I hope I made this clear. TIA

Ric
 
One thing you could use to check whether the password field in the main
table is blank is the DLookup() function:

=DLookup("TableName", "FieldName", "uniqueFieldName = '" &
[uniqueFieldName] & "'")

That might seem cryptic without an explanation, but Allen Browne has an
excellent web page that explains it clearly at:

http://allenbrowne.com/casu-07.html

Be sure to pay very close attention to the punctuation, especially where
there are quotation marks. For example, the last four characters in that
expression above are 1) a double quote, ", 2) a single quote, ', 3) another
double quote, ", and finally the closing parenthesis, ).

On his web page, Allen explains explains the punctuation that should be used
depending on whether the "uniqueFieldName" (in my terminology) is numeric or
text. And there's a difference, so be sure to take that into account.

To test for null values, you could use either

If IsNull(Dlookup( . . . )) Then . . .

or

If Len(NZ(DLookup( . . . ))) = 0 Then . . .

I think either of those would work, but I bet some of the expert
contributors could tell you that one would be better to use than the others.

hth

Paul
 
Ric,

Something like this:

If IsNull(DLookup("[Password]","MainTable","[UserID]=" & Me.UserID)) Then
' bypass
Else
... your 'old password' verification code
End If
 
Ric,
Something like this:

If IsNull(DLookup("[Password]","MainTable","[UserID]=" & Me.UserID)) Then
' bypass
Else
... your 'old password' verification code
End If


That's great Steve, it worked perfectly! Thanks very much.
I was just about to write back because I wasn't getting anywhere with
the other code that was suggested.

Ric
 
Back
Top