There is the code:
Private Sub ListMonths_Click()
DoCmd.OpenReport "ReportPTMonth", acViewPreview, , "Month([DateOfTest])
=
"&
Me.ListMonths
End Sub
Do you think it could be my Access version 2003? I am dealing with two
errors. On the other form Visit, I have a combo box that open a form
Subjects, and whrn I add new record it show the error : I cannot add
because
the record it been used on table Visit. I searched all the codes, on
Allen's,
on examples over here, and nothing. The code is for Not in list cbo
event.
Should it have a code on the after updade also? I know it is simple
however
for any reason it have been a nigthmare, I can't even sleep. HELP ME!
:
And the report opens fine if you don't have the criteria?
Your syntax looks correct. I don't know what could be wrong.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Hi Douglas,
i put code on the immediate and hit enter showed the number 6 and I
daved
it, when i tried to check it ocurred the same syntax error. Yes,
the
Multiselect is set to NOne.
:
That will only work if ListMonths has its Multiselect property set
to
None.
If you select something in the list box then go to the immediate
window
(Ctrl-G), type
?Forms![NameOfForm]!ListMonths
(using the actual form name where it says "NameOfForm") then hit
enter,
what
do you get?
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Private Sub ListMonths_Click()
DoCmd.OpenReport "ReportPTMonth", acViewPreview, ,
"Month([DateOfTest])
=
"&
Me.ListMonths
:
Did you add the quote after the = sign as I suggested? Please
post
the
line
of code if you continue to have problems.
You are correct, lstMonths is the list box name.
Thanks Bruce for your help. I am getting a syntax error now;
I've
changed
to
my report name. Just to be sure lstmonths is the list box
name,
right?I've
changed also. TIA
:
Try closing the quote:
DoCmd.OpenReport "ReportName", acViewPreview, ,
"Month([DateOfTest]) =
"
&
Me.lstMonths
Use your own control name and report name, of course. I
think
you
have
done
that, but I'll mention it just to be sure.
Thanks a bunch Arvin, I put the code at the on click event
and
I
got
an
"compile error:invalid use of property", and it highlight
the
Me.ListMonths.
TIA
:
DoCmd.OpenReport "ReportName", acViewPreview,,
"Month([DateOfTest])
=
&
Me.lstMonths
Put the month numbers in the first, bound column of your
listbox
and
set
the
width of that column to 0" so it won't be seen.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
message
I have a report group by month, where on the query I have
a
expxression:Expr1: Format([DateOfTEst],"mmmm/yyyy").
My question is: can I have a list box with month
January,
February,
etc...;
so when the user check on the month i have the report on
that
month.
I've
searched on the threads but it have start date and end
date,
which
is
not
my
case. TIA