"Missing operator" error

bulrush

Registered User.
Local time
Yesterday, 21:39
Joined
Sep 1, 2009
Messages
209
I'm getting "3075 Missing operator in Getfirst(MM.[UPCPLU],"","") as MyPLU " error in this sql statement:
Code:
SELECT MM.GID, MM.NmProd1, MM.UPCPLU, MM.FoodCat, Max(MD.Jobno) AS LastJob, MM.C3x5, MM.H3x5, 
MM.O3x5, GetFirst([MM.UPCPLU],"","") as MyPLU, MM.MWID, MM.ProductClass, MM.Itemdesc1 
FROM MM LEFT JOIN MD ON MM.GID = MD.GID 
GROUP BY MM.GID, MM.NmProd1, MM.UPCPLU, MM.FoodCat, Len([PSIJobNum]), MM.C3x5, 
MM.H3x5, MM.O3x5, GetFirst(MM.[UPCPLU],"","") as MyPLU, MM.MWID, MM.ProductClass, MM.Itemdesc1 HAVING ( 
(MM.Foodcat='Wetveg') and (nz(MM!C3x5)>0) ) OR 
((MM.Foodcat='Wetveg') and (nz(MM!H3x5)>0) ) OR 
((MM.Foodcat='Wetveg') and (nz(MM!O3x5)>0) 
 ) 
ORDER BY MM.NmProd1 ;
I have no clue why. Anyone see any problem here?
 
Want to show us the code for GetFirst()?

Did you mean First or FindFirst?
 
GetFirst gets the first value in a list separated by commas.
Code:
Public Function GetFirst(src As Variant, delim As String) As String
' Get first string from "src" delimited by "delim".
' Ex: src="1234,5544" delim=",", this returns "1234"
' LOG
' 12-27-10 If src is empty, just return src.
Dim s As String
Dim i As Integer, j As Integer, l As Integer
Dim dest As String

On Error GoTo MyError

src = Nz(src)
GetFirst = src
If (Len(Trim(src)) > 0) Then
    l = InStr(src, delim)
    If (l > 0) Then
        dest = Left(src, l - 1)
        GetFirst = dest
    End If
End If

Exit Function

MyError:
    Call DispError("GetFirst")
    If (gUsername = "chuck") Then
        Stop
        Resume Next
    Else
        Exit Function
    End If

End Function
 
This is a side note, but if you use the Split Function it can save you some code:
Code:
Public Function GetFirst(src As Variant, delim As String) As String
' Get first string from "src" delimited by "delim".
' Ex: src="1234,5544" delim=",", this returns "1234"
' LOG
' 12-27-10 If src is empty, just return src.
Dim varSplit As Variant
 
On Error GoTo MyError
 
varSplit = Split(src, delim, , vbTextCompare)
 
GetFirst = varSplit(0)
 
Exit Function
 
MyError:
    Call DispError("GetFirst")
    If (gUsername = "chuck") Then
        Stop
        Resume Next
    Else
        Exit Function
    End If
End Function
 
According to your GetFirst function
Public Function GetFirst(src As Variant, delim As String) As String
' Get first string from "src" delimited by "delim".
' Ex: src="1234,5544" delim=",", this returns "1234"

You are expecting 2 parameters 'src' and 'delim'.

However, in your query
....
GetFirst([MM.UPCPLU],"","") as MyPLU......
you have 3 parameters.

I think you need to sort out what your delimiter is in the function call in the query.
 
But after looking at your code I can see the problem it is this part in red:

GetFirst(MM.[UPCPLU],"","") as MyPLU

It SHOULD be:

GetFirst(MM.[UPCPLU], ",") as MyPLU
 
I have a question so where do I ask it?

In the main forum list, click on the category where your question should be (do your best to figure it out, if not sure, post to general and it might be moved by a mod to the right location). Then from there you should see a button on the top left of the page that says NEW THREAD. Click on that and fill in the blanks.
 

Users who are viewing this thread

Back
Top Bottom