Rabu, 05 Oktober 2011

[MS_AccessPros] Invalid use of Null

 

In the AfterUpdate Event for entering the buyer (ContactID) in a subform of the Sales form I have code that is checking to see if that buyer was involved in a looking event. If so, the LookingEvent form is opened and they are asked to enter an ending date.

It is working in two of three cases:
-If there is a contact in the LookingContacts table and there is no end date entered in the LookingEvent table
-If there is a contact in Looking Contacts table and there is an end date entered in the LookingEvent table

I am getting the Invalid Use of Null error message if the contact is not in the LookingContacts table and there is no LookingID associated with him and therefore no record in the LookingEvents table.

I don't think I have to use the NZ in the lngL statement since entering the ContactID is what prompts the code to begin.

Code is below. Thanks!!!
Connie

lngL = DLookup("LookingID", "LookingContacts", "ContactID = " & Nz([ContactID], 0))

If ((Not IsNull(lngL)) And (lngL > 0) And (IsNull(DLookup("EndDate", "LookingEvent", "LookingID = " & Nz(lngL, 0))))) Then
DoCmd.OpenForm "LookingEvent", , , ("LookingID = " & lngL)
MsgBox "Are these contacts no longer buyers?" _
& vbNewLine & "Then enter an ending date"
End If

__._,_.___
Recent Activity:
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar