Invalid syntax

M

Mitch

Hello....
trying to refer to a control on a form in a query that
will be the datasource for a subform, but it keeps
complaining about invalid syntax. Here is the text I am
suing in the criteria field for the query....


Between [forms]![frmcal].[cboMonth].[Value] & "/01/04"
And [forms]![frmcal].[cboMonth].[Value]]] & "/" & [forms]!
[frmcal].[txtmonth].[value] & "/04"
 
W

Wayne Morgan

Dates need date delimiters (#) around them so Access treats them as dates
and not division problems. Also, for the second date it appears you may be
entering the month twice (judging by the names cboMonth and txtMonth).

Between "#" & [forms]![frmcal].[cboMonth].[Value] & "/01/04#" And "#" &
[forms]![frmcal].[cboMonth].[Value] & "/" &
[forms]![frmcal].[txtmonth].[value] & "/04#"

Another possible problem is that one of the values is coming from a
Combobox. If you have only one column in the combobox this may not be a
problem, but if you have more than one, remember that the value of the
combobox comes from the Bound Column which may not be the visible column.
 
G

Guest

Thanks Wayne.
Yeah, the cboBox has two columns but the first column is
the correct column since I want the numerical value for
the query. After I posted I also realsied that there were
3 ] after the value. The txtmonth textbox actually
carries the number of days for the month, not the month
itself, sorry, should have pointed that out.
Thanks again for your help.
-----Original Message-----
Dates need date delimiters (#) around them so Access treats them as dates
and not division problems. Also, for the second date it appears you may be
entering the month twice (judging by the names cboMonth and txtMonth).

Between "#" & [forms]![frmcal].[cboMonth].[Value] & "/01/04#" And "#" &
[forms]![frmcal].[cboMonth].[Value] & "/" &
[forms]![frmcal].[txtmonth].[value] & "/04#"

Another possible problem is that one of the values is coming from a
Combobox. If you have only one column in the combobox this may not be a
problem, but if you have more than one, remember that the value of the
combobox comes from the Bound Column which may not be the visible column.


--
Wayne Morgan
MS Access MVP


Hello....
trying to refer to a control on a form in a query that
will be the datasource for a subform, but it keeps
complaining about invalid syntax. Here is the text I am
suing in the criteria field for the query....


Between [forms]![frmcal].[cboMonth].[Value] & "/01/04"
And [forms]![frmcal].[cboMonth].[Value]]] & "/" & [forms]!
[frmcal].[txtmonth].[value] & "/04"


.
 
Top