syntax error

  • Thread starter warrenjburns via AccessMonster.com
  • Start date
W

warrenjburns via AccessMonster.com

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.
 
J

John W. Vinson

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='.

What do you WANT to happen when there is nothing in Me.RecipeIngredient?

Perhaps you should just check to see if the value is NULL or blank before
running your code:

If Me!RecipeIngredient & "" = "" Then
MsgBox "Please select an ingredient", vbOKOnly
Else
<your code>
 

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