Results 1 to 2 of 2

Thread: syntax error

  1. #1
    Join Date
    Apr 2009
    Posts
    4

    Unanswered: syntax error

    Hi,

    I have a syntax error... the problem is when the Me.RecipeIngredient not selected the builder still requires a value for the join and or strSQL... I think?

    When the Me.RecipeIngredient is selected the expression work very well and builder and select values from form and subform and BuildFilter accordingly.

    The error is:

    Run-time error '3075':

    Syntax error (missing operator) in query expression
    'RecipeIngredients.RecipeIngredientID='.

    The expression is:

    Private Sub SearchButton_Click()

    Dim strSQL As String, strWhere As String

    If IsNull(Me.RecipeIngredient) Then
    strSQL = "SELECT * FROM BeveragesSearch"
    strWhere = BuildFilter(" WHERE ")

    Else
    strSQL = "SELECT BeveragesSearch.* FROM BeveragesSearch " & _
    "INNER JOIN RecipeIngredients ON " & _
    "BeveragesSearch.IngredientID = RecipeIngredients.IngredientID " & _
    "WHERE RecipeIngredients.RecipeIngredientID = " & Me.RecipeIngredient
    strWhere = BuildFilter(" AND ")

    End If

    strSQL = strSQL & strWhere
    Me.Beverages.Form.RecordSource = strSQL
    Me.Beverages.Requery

    End Sub

    Please help

    Warren.

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    My first guess would be this:

    Code:
    Private Sub SearchButton_Click()
      Dim strSQL As String, strWhere As String
      If IsNull(Me.RecipeIngredient) Then
        strSQL = "SELECT * FROM BeveragesSearch"
      Else
        strSQL = "SELECT BeveragesSearch.* FROM BeveragesSearch " & _
        "INNER JOIN RecipeIngredients ON " & _
        "BeveragesSearch.IngredientID = RecipeIngredients.IngredientID " & _
        "WHERE RecipeIngredients.RecipeIngredientID = " & Me.RecipeIngredient
        strWhere = BuildFilter(" AND ")
        strSQL = strSQL & strWhere
      End If
      Me.Beverages.Form.RecordSource = strSQL
      Me.Beverages.Requery
    End Sub
    But I don't know anything about BuildFilter().
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •