View Single Post
  #1  
Old July 7th, 2009, 03:08 PM posted to microsoft.public.access
Pwyd
external usenet poster
 
Posts: 114
Default Before-update reference on a field

Private Sub V_InvoiceNumber_BeforeUpdate(Cancel As Integer)

If DLookup("[V_InvoiceNumber]", "[VendorRecordsTable]", "Not
IsNull([V_InvoiceNumber]=[Forms]![Main Record]![V_InvoiceNumber]) ") Then
If MsgBox("Invoice number already exists. Continue?", vbYesNo, _
"Invoice Number Duplicate") = vbNo Then
Cancel = True
End If
End If

End Sub


this is currently sitting in the "before update" field, happily provided to
me by some other access database helpers here in the community. However
after testing it, it ALWAYS asks whether i want to cancel, regardless of
wehther the invoice number is actually a duplicate. I've read the reference
on IsNull and what it resolves to, and i'm not sure wehther this is what i
want, however i'm not sure what i should replace it with. Nz() perhaps? i
was only trying to prevent it from trying to do a comparison of "null" to a
string "null" which i'm told is invalid.