Missing Operator

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Missing Operator

Post by Leesha »

Hi,
I'm using the code below to alert the user if there is no remaining inventory. I'm getting an error that states there is a missing operator and it points to "15MLInventory". I'm not sure what it is looking for.
Thanks,
Leesha

If (DLookup("15MLInventory", "qryInventoryEO")) = 0 Then
MsgBox "You have no 15 ml bottles of this oil in inventory. Do you wish to continue adding it to the invoice?"
Exit Sub
Else:

If Not IsNull(Forms!frmInvoice!sfrmInvoice!RecipeItemName) Then
MsgBox "Please select the next blank line as there is already an item listed in the row that is selected."
Exit Sub
Else:

Forms!frmInvoice!sfrmInvoice!RecipeItemName = Me.cmbEO.Column(1)
Forms!frmInvoice!sfrmInvoice!RetailItemCost = Me.txt15MLRetailCharge
Forms!frmInvoice!sfrmInvoice!WholesaleItemCost = Me.txt15mlWholesaleCharge

Me.txtDropsforRecipe = Null
Forms!frmInvoice!sfrmInvoice.SetFocus

End If
End If

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Missing Operator

Post by HansV »

Just a wild guess: does the following work?

If (DLookup("[15MLInventory]", "qryInventoryEO")) = 0 Then
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Re: Missing Operator

Post by Leesha »

Great guess! Worked like a charm! Thanks!

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Missing Operator

Post by HansV »

It is because Access and SQL don't like names beginning with a digit. Enclosing the name in [ ] prevents the error message.
Best wishes,
Hans

Gasman
StarLounger
Posts: 81
Joined: 22 Feb 2022, 09:04

Re: Missing Operator

Post by Gasman »

PMFJI,
DLookUp() returns Null if nothing found?
Using Access 2007.
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Please, please use code tags when posting code snippets, click the </>icon.
Debug.Print is your lifesaver.