Error 3075

  • Thread starter Thread starter Brendan Reynolds
  • Start date Start date
B

Brendan Reynolds

You might be missing a space. Try ...
strCond = strCond & " Order By .. etc"

Note the space in front of 'Order By'.

If that's not it, try posting enough of the code so that we can see what
strCond may already contain before the 'Order By' clause is appended.
 
Hi to all,

I and trying to build a string condition to use with the Docmd.OpenReport,
in that sting, I need to insert the ORBER BY condition but when I do I get
the error 3075 Syntax error....missing operator in query expression.....
If I do not add the ORDER BY condition , all the other condition (Where
Clause) are working just great

If cboSort1.Value = "Not Sorted" Or IsNull(cboSort1) Then
strCond = strCond & "ORDER BY BusinessGroup,Pays"
Else
...........
End If

'open report
DoCmd.OpenReport stDocName, acPreview, , strCond
If Err.Number = 2501 Then Err.Clear

TIA

Alain
 
I already tried it with the space before I post and it gives me the error

Here is the code:

'sélection d'un business group
If cboBussGroup.Value <> "" Then
strCond = "BusinessGroup like '" & Me.cboBussGroup.Value & "'"
ElseIf IsNull(cboBussGroup.Value) Then
strCond = strCond
End If
'sélection du surplus
If Check7 = True Then
strCond = strCond & " And Surplus = True"
ElseIf Check9 = True Then
strCond = strCond & " And Surplus = False"
ElseIf Check7 = False And Check9 = False Then
strCond = strCond
End If
'sélection d'un property type
If cboPropType.Value <> "" Then
strCond = strCond & " And PropertyType like '" & Me.cboPropType.Value
& "'"
ElseIf IsNull(cboPropType.Value) Then
strCond = strCond
End If
'sélection d'un continent
If cboContinent.Value <> "" Then
strCond = strCond & " And Continent like '" & Me.cboContinent.Value &
"'"
ElseIf IsNull(cboContinent.Value) Then
strCond = strCond
End If
'sélection d'un pays
If cboCountry.Value <> "" Then
strCond = strCond & " And Pays like '" & Me.cboCountry.Value & "'"
ElseIf IsNull(cboCountry.Value) Then
strCond = strCond
End If

'CONSTRUCTION DE LA CLAUSE WHERE AVEC SORTING
If cboSort1.Value = "Not Sorted" Or IsNull(cboSort1) Then
strCond = strCond & " ORDER BY BusinessGroup,Pays"
Else
strCond = strCond & "[" & Me.cboSort1.Value & "]"
End If

' Debug.Print strCond

'open report
DoCmd.OpenReport stDocName, acPreview, , strCond
If Err.Number = 2501 Then Err.Clear


Alain
 
You can't use ORDER BY in the wherecondition parameter of the OpenReport
command. All you can put there is a WHERE clause (without the word WHERE)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Alain said:
I already tried it with the space before I post and it gives me the error

Here is the code:

'sélection d'un business group
If cboBussGroup.Value <> "" Then
strCond = "BusinessGroup like '" & Me.cboBussGroup.Value & "'"
ElseIf IsNull(cboBussGroup.Value) Then
strCond = strCond
End If
'sélection du surplus
If Check7 = True Then
strCond = strCond & " And Surplus = True"
ElseIf Check9 = True Then
strCond = strCond & " And Surplus = False"
ElseIf Check7 = False And Check9 = False Then
strCond = strCond
End If
'sélection d'un property type
If cboPropType.Value <> "" Then
strCond = strCond & " And PropertyType like '" & Me.cboPropType.Value
& "'"
ElseIf IsNull(cboPropType.Value) Then
strCond = strCond
End If
'sélection d'un continent
If cboContinent.Value <> "" Then
strCond = strCond & " And Continent like '" & Me.cboContinent.Value &
"'"
ElseIf IsNull(cboContinent.Value) Then
strCond = strCond
End If
'sélection d'un pays
If cboCountry.Value <> "" Then
strCond = strCond & " And Pays like '" & Me.cboCountry.Value & "'"
ElseIf IsNull(cboCountry.Value) Then
strCond = strCond
End If

'CONSTRUCTION DE LA CLAUSE WHERE AVEC SORTING
If cboSort1.Value = "Not Sorted" Or IsNull(cboSort1) Then
strCond = strCond & " ORDER BY BusinessGroup,Pays"
Else
strCond = strCond & "[" & Me.cboSort1.Value & "]"
End If

' Debug.Print strCond

'open report
DoCmd.OpenReport stDocName, acPreview, , strCond
If Err.Number = 2501 Then Err.Clear


Alain
 
Douglas said:
You can't use ORDER BY in the wherecondition parameter of the OpenReport
command. All you can put there is a WHERE clause (without the word WHERE)
I already tried it with the space before I post and it gives me the error
[quoted text clipped - 80 lines]

Furthermore, You need at least a SELECT statement in order to use the WHERE
or the ORDER BY keywords.
 
Alain said:
I already tried it with the space before I post and it gives me the error

Here is the code:

'sélection d'un business group
If cboBussGroup.Value <> "" Then
strCond = "BusinessGroup like '" & Me.cboBussGroup.Value & "'"
ElseIf IsNull(cboBussGroup.Value) Then
strCond = strCond
End If
'sélection du surplus
If Check7 = True Then
strCond = strCond & " And Surplus = True"
ElseIf Check9 = True Then
strCond = strCond & " And Surplus = False"
ElseIf Check7 = False And Check9 = False Then
strCond = strCond
End If
'sélection d'un property type
If cboPropType.Value <> "" Then
strCond = strCond & " And PropertyType like '" & Me.cboPropType.Value
& "'"
ElseIf IsNull(cboPropType.Value) Then
strCond = strCond
End If
'sélection d'un continent
If cboContinent.Value <> "" Then
strCond = strCond & " And Continent like '" & Me.cboContinent.Value &
"'"
ElseIf IsNull(cboContinent.Value) Then
strCond = strCond
End If
'sélection d'un pays
If cboCountry.Value <> "" Then
strCond = strCond & " And Pays like '" & Me.cboCountry.Value & "'"
ElseIf IsNull(cboCountry.Value) Then
strCond = strCond
End If

'CONSTRUCTION DE LA CLAUSE WHERE AVEC SORTING
If cboSort1.Value = "Not Sorted" Or IsNull(cboSort1) Then
strCond = strCond & " ORDER BY BusinessGroup,Pays"
Else
strCond = strCond & "[" & Me.cboSort1.Value & "]"
End If

' Debug.Print strCond

'open report
DoCmd.OpenReport stDocName, acPreview, , strCond
If Err.Number = 2501 Then Err.Clear

Alain
You might be missing a space. Try ...
strCond = strCond & " Order By .. etc"
[quoted text clipped - 26 lines]

Try this

If cboSort1.Value = "Not Sorted" Or IsNull(cboSort1) Then
strCond = strCond & "SELECT BusinessGroup, Pays ORDER BY BusinessGroup,
Pays"
Else
strCond = strCond & "[" & Me.cboSort1.Value & "]"
End If
 
Um, Adam, he's providing a WHERE condition for the OpenReport statement:

DoCmd.OpenReport stDocName, acPreview, , strCond

And even if he did need to include a SELECT clause, it would need to be
something like:

strCond = "SELECT BusinessGroup, Pays FROM MyTable WHERE " & _
strcond & " ORDER BY BusinessGroup, Pays"


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Adam Turner via AccessMonster.com said:
Alain said:
I already tried it with the space before I post and it gives me the error

Here is the code:

'sélection d'un business group
If cboBussGroup.Value <> "" Then
strCond = "BusinessGroup like '" & Me.cboBussGroup.Value & "'"
ElseIf IsNull(cboBussGroup.Value) Then
strCond = strCond
End If
'sélection du surplus
If Check7 = True Then
strCond = strCond & " And Surplus = True"
ElseIf Check9 = True Then
strCond = strCond & " And Surplus = False"
ElseIf Check7 = False And Check9 = False Then
strCond = strCond
End If
'sélection d'un property type
If cboPropType.Value <> "" Then
strCond = strCond & " And PropertyType like '" &
Me.cboPropType.Value
& "'"
ElseIf IsNull(cboPropType.Value) Then
strCond = strCond
End If
'sélection d'un continent
If cboContinent.Value <> "" Then
strCond = strCond & " And Continent like '" & Me.cboContinent.Value
&
"'"
ElseIf IsNull(cboContinent.Value) Then
strCond = strCond
End If
'sélection d'un pays
If cboCountry.Value <> "" Then
strCond = strCond & " And Pays like '" & Me.cboCountry.Value & "'"
ElseIf IsNull(cboCountry.Value) Then
strCond = strCond
End If

'CONSTRUCTION DE LA CLAUSE WHERE AVEC SORTING
If cboSort1.Value = "Not Sorted" Or IsNull(cboSort1) Then
strCond = strCond & " ORDER BY BusinessGroup,Pays"
Else
strCond = strCond & "[" & Me.cboSort1.Value & "]"
End If

' Debug.Print strCond

'open report
DoCmd.OpenReport stDocName, acPreview, , strCond
If Err.Number = 2501 Then Err.Clear

Alain
You might be missing a space. Try ...
strCond = strCond & " Order By .. etc"
[quoted text clipped - 26 lines]

Try this

If cboSort1.Value = "Not Sorted" Or IsNull(cboSort1) Then
strCond = strCond & "SELECT BusinessGroup, Pays ORDER BY
BusinessGroup,
Pays"
Else
strCond = strCond & "[" & Me.cboSort1.Value & "]"
End If
 
Doh!

Thanks Doug! :-)

--
Brendan Reynolds

Douglas J. Steele said:
You can't use ORDER BY in the wherecondition parameter of the OpenReport
command. All you can put there is a WHERE clause (without the word WHERE)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Alain said:
I already tried it with the space before I post and it gives me the error

Here is the code:

'sélection d'un business group
If cboBussGroup.Value <> "" Then
strCond = "BusinessGroup like '" & Me.cboBussGroup.Value & "'"
ElseIf IsNull(cboBussGroup.Value) Then
strCond = strCond
End If
'sélection du surplus
If Check7 = True Then
strCond = strCond & " And Surplus = True"
ElseIf Check9 = True Then
strCond = strCond & " And Surplus = False"
ElseIf Check7 = False And Check9 = False Then
strCond = strCond
End If
'sélection d'un property type
If cboPropType.Value <> "" Then
strCond = strCond & " And PropertyType like '" &
Me.cboPropType.Value & "'"
ElseIf IsNull(cboPropType.Value) Then
strCond = strCond
End If
'sélection d'un continent
If cboContinent.Value <> "" Then
strCond = strCond & " And Continent like '" & Me.cboContinent.Value
& "'"
ElseIf IsNull(cboContinent.Value) Then
strCond = strCond
End If
'sélection d'un pays
If cboCountry.Value <> "" Then
strCond = strCond & " And Pays like '" & Me.cboCountry.Value & "'"
ElseIf IsNull(cboCountry.Value) Then
strCond = strCond
End If

'CONSTRUCTION DE LA CLAUSE WHERE AVEC SORTING
If cboSort1.Value = "Not Sorted" Or IsNull(cboSort1) Then
strCond = strCond & " ORDER BY BusinessGroup,Pays"
Else
strCond = strCond & "[" & Me.cboSort1.Value & "]"
End If

' Debug.Print strCond

'open report
DoCmd.OpenReport stDocName, acPreview, , strCond
If Err.Number = 2501 Then Err.Clear


Alain



Brendan Reynolds said:
You might be missing a space. Try ...
strCond = strCond & " Order By .. etc"

Note the space in front of 'Order By'.

If that's not it, try posting enough of the code so that we can see what
strCond may already contain before the 'Order By' clause is appended.

--
Brendan Reynolds


Hi to all,

I and trying to build a string condition to use with the
Docmd.OpenReport, in that sting, I need to insert the ORBER BY
condition but when I do I get the error 3075 Syntax error....missing
operator in query expression.....
If I do not add the ORDER BY condition , all the other condition (Where
Clause) are working just great

If cboSort1.Value = "Not Sorted" Or IsNull(cboSort1) Then
strCond = strCond & "ORDER BY BusinessGroup,Pays"
Else
...........
End If

'open report
DoCmd.OpenReport stDocName, acPreview, , strCond
If Err.Number = 2501 Then Err.Clear

TIA

Alain
 
Back
Top