Error 3075 - Missing Operator

kermit5

Registered User.
Local time
Today, 21:17
Joined
Nov 2, 2001
Messages
122
Here is my code
Code:
Dim intMasterProjectID, intContractorListID As Integer
    Dim strSQL, strContractor As String
    Dim dbs As Database
    Dim rs As dao.Recordset
    
    intMasterProjectID = Forms![Bid - Master Form]![Master Project ID]
    strContractor = Forms![Bid - Master Form]![Bid - Bid Follow Up]![FollowupContractor]
    strSQL = "SELECT * FROM [Bid - Contractor List]" & _
            "WHERE [Bid - Contractor List].[Contractor] = " & strContractor & _
            " AND [Bid - Contractor List].[Master Project ID] = " & intMasterProjectID
            
    Debug.Print "Project ID: " & intMasterProjectID
    Debug.Print "Contractor: " & strContractor
    Debug.Print "SQL: " & strSQL
    Set dbs = CurrentDb
    Set rs = dbs.OpenRecordset(strSQL)

I get error 3075 in my strSQL statement (syntax error (missing operator) in query expression...). Any Ideas?

Here is my SQL statement from my immediate window:
Code:
SQL: SELECT * FROM [Bid - Contractor List]WHERE [Bid - Contractor List].[Contractor] = Bud Bailey Construction AND [Bid - Contractor List].[Master Project ID] = -8585313

Thanks
 
Do you need the ; at the end of the sql?

Fuga.
 
I'm not sure I understand what you are asking?

If I include a semi-colon here:
Code:
strSQL = "SELECT * FROM [Bid - Contractor List] As myTable " & _
            "WHERE myTable.Contractor = " & strContractor & _
            " AND myTable.[Master Project ID] = " & intMasterProjectID;
I get a compile error: expected end of statement.
 
Last edited:
I don´t really know what I´m talking about here, but I noticed a sql I have in a module and it end with the ; (I was trying to make a blue semicolon, hmm...)

Code:
    strSQL = "SELECT * FROM [Bid - Contractor List]" & _
            "WHERE [Bid - Contractor List].[Contractor] = " & strContractor & _
            " AND [Bid - Contractor List].[Master Project ID] = " & intMasterProjectID [b]& ";"[/b]

Like I said, just a thought.

Fuga.
 
Ok, then I´m sorry I don´t know. Maybe the problem is in the strcontractor line?

Fuga.
 
Thank you. You were correct. Here is what it required:
Code:
strSQL = "SELECT * FROM [Bid - Contractor List] " & _
            "WHERE [Master Project ID] = " & intMasterProjectID & _
            "AND [Contractor] = '" & strContractor & "'"
Because strContractor is a string variable, I need to set it off with single quotation marks in my SQL statement.

Thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom