By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,256 Members | 1,663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,256 IT Pros & Developers. It's quick & easy.

If blah blah blah #AND# If Not blah blah blah produce same results. Why?

P: n/a
MLH
if DLookup("[cSSN]", "tblAddressesEquifax",
"[cSSN]=GetCurrentMemberID()") then ? "Hello"

#AND#

if not DLookup("[cSSN]", "tblAddressesEquifax",
"[cSSN]=GetCurrentMemberID()") then ? "Hello"

both result in "Hello" being printed in the immediate
window. Access 2.0. Why???
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi

IMHO, you're using the wrong syntax.
I believe that the criteria that you have in your DLookup will *always*
return one of two things ...
The value of "[cSSN]" (If it exists, ... and I assume that it is supposed
to be numeric) or Null (If it doesn't)

Try it this way:
*************************************
Private Sub Command0_Click()

Dim varFindThis
varFindThis = GetCurrentMemberID()

If IsNumeric(varFindThis) Then ' I'm assuming that the function is supposed
to return a numeric "ID" here

If Not IsNull(DLookup("[cSSN]", "tblAddressesEquifax", "[cSSN] =" &
varFindThis)) Then
Debug.Print "Hello"
Else
Debug.Print "Goodbye"
End If

End If

End Sub
*************************************

Note: This is the *actual* code that I used during testing, which seemed to
work fine:
*************************************
Private Sub Command0_Click()
Dim varFindThis
varFindThis = InputBox("Enter a numeric value to find", "Find a Value")

If IsNumeric(varFindThis) Then

If Not IsNull(DLookup("FacultyName", "tblFaculty", "[FacID] =" &
varFindThis)) Then
Debug.Print "Hello"
Else
Debug.Print "Goodbye"
End If

End If

End Sub
*************************************

--
HTH,
Don
=============================
E-Mail (if you must)
My*****@Telus.net

Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.

Do Until SinksIn = True
File/Save, <slam fingers in desk drawer>
Loop

================================

"MLH" <CR**@NorthState.net> wrote in message
news:ti********************************@4ax.com...
if DLookup("[cSSN]", "tblAddressesEquifax",
"[cSSN]=GetCurrentMemberID()") then ? "Hello"

#AND#

if not DLookup("[cSSN]", "tblAddressesEquifax",
"[cSSN]=GetCurrentMemberID()") then ? "Hello"

both result in "Hello" being printed in the immediate
window. Access 2.0. Why???

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.