The expression you entered as a query parameter produced this erro

R

Ricter

"The expression you entered as a query parameter produced this error: 'The
object doesn't contain the Automation object 'subInvoices.VendorInvNum.''"

After update, the field mentioned is checked for a preexisting, duplicate
value.

It has always worked, up until a couple of weeks ago, when I started getting
this popup, and I have not changed anything in my db.

Any theories, please? Code follows...


Private Sub VendorInvNum_AfterUpdate()

Me.VendorInvNum = UCase(Me.VendorInvNum)

On Error GoTo VendorInvNum_AfterUpdate_Err

If Not IsNull(DLookup("InvoiceID", "tblInvoices", "VendorInvNum =
[subInvoices].[VendorInvNum]")) Then
MsgBox "Hey, you've referenced that invoice number before!", vbOKOnly,
"Invoice Number Checker"
End If
VendorInvNum_AfterUpdate_Exit:
Exit Sub
VendorInvNum_AfterUpdate_Err:
MsgBox Error$
Resume VendorInvNum_AfterUpdate_Exit

End Sub
 
J

John Spencer

The problem is that [subInvoices].[VendorInvNum] is not known to the query
engine. IF SubInvoice is the name of the form you can use

If Not
IsNull(DLookup("InvoiceID", "tblInvoices",
"VendorInvNum = """ & Me.[VendorInvNum] & """")) Then

OR you can use
(DLookup("InvoiceID", "tblInvoices",
"VendorInvNum = Forms!subInvoices![VendorInvNum]")

If that errors, tell us what subInvoices is? Is it a subform on a mainform?

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
R

Ricter

John, that first suggestion worked, thank you!

Not sure why the old code quit working...

Rick


John Spencer said:
The problem is that [subInvoices].[VendorInvNum] is not known to the query
engine. IF SubInvoice is the name of the form you can use

If Not
IsNull(DLookup("InvoiceID", "tblInvoices",
"VendorInvNum = """ & Me.[VendorInvNum] & """")) Then

OR you can use
(DLookup("InvoiceID", "tblInvoices",
"VendorInvNum = Forms!subInvoices![VendorInvNum]")

If that errors, tell us what subInvoices is? Is it a subform on a mainform?

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
"The expression you entered as a query parameter produced this error: 'The
object doesn't contain the Automation object 'subInvoices.VendorInvNum.''"

After update, the field mentioned is checked for a preexisting, duplicate
value.

It has always worked, up until a couple of weeks ago, when I started getting
this popup, and I have not changed anything in my db.

Any theories, please? Code follows...


Private Sub VendorInvNum_AfterUpdate()

Me.VendorInvNum = UCase(Me.VendorInvNum)

On Error GoTo VendorInvNum_AfterUpdate_Err

If Not IsNull(DLookup("InvoiceID", "tblInvoices", "VendorInvNum =
[subInvoices].[VendorInvNum]")) Then
MsgBox "Hey, you've referenced that invoice number before!", vbOKOnly,
"Invoice Number Checker"
End If
VendorInvNum_AfterUpdate_Exit:
Exit Sub
VendorInvNum_AfterUpdate_Err:
MsgBox Error$
Resume VendorInvNum_AfterUpdate_Exit

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top