View Single Post
  #6  
Old July 8th, 2009, 06:01 PM posted to microsoft.public.access
Clifford Bass[_2_]
external usenet poster
 
Posts: 1,295
Default Before-update reference on a field

Hi,

Ah, an erroneous typo. Is V_InvoiceNumber defined as an actual number
or is it defined as text? If text, chante this:

= " & [V_InvoiceNumber]))

to:

= """ & Replace([V_InvoiceNumber], """", """""") & """"))

Note that those are all quotes (") not apostrophes ('). The Replace()
function makes sure that you do construct an invalid invoice number clause,
in the odd event that someone has entered a quote symbol into the invoice
number.

If that is not the issue, post back.

Clifford Bass

"Pwyd" wrote:

i removed the extra _ you put in InvoiceNumber in the criteria part of the
expression, now its giving me a data type mismatch?


Private Sub V_InvoiceNumber_BeforeUpdate(Cancel As Integer)

If IsNull([V_InvoiceNumber]) Then
MsgBox "Please enter an invoice number."
Cancel = True
Else
If Not IsNull(DLookup("[V_InvoiceNumber]", "[VendorRecordsTable]",
"[V_InvoiceNumber] = " & [V_InvoiceNumber])) Then
If MsgBox("Invoice number already exists. Continue?", vbYesNo, _
"Invoice Number Duplicate") = vbNo Then
Cancel = True
End If
End If
End If


End Sub