It is possible?

S

Sylvie

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
 
A

Arvin Meyer [MVP]

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

Sylvie

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

Arvin Meyer said:
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


Sylvie said:
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
 
B

BruceM

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.


Sylvie said:
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

Arvin Meyer said:
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


Sylvie said:
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
 
S

Sylvie

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

BruceM said:
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.


Sylvie said:
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

Arvin Meyer said:
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


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
 
B

BruceM

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.

Sylvie said:
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

BruceM said:
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.


Sylvie said:
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


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
 
S

Sylvie

Private Sub ListMonths_Click()
DoCmd.OpenReport "ReportPTMonth", acViewPreview, , "Month([DateOfTest]) = "&
Me.ListMonths

BruceM said:
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.

Sylvie said:
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

BruceM said:
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


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
 
D

Douglas J. Steele

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!)


Sylvie said:
Private Sub ListMonths_Click()
DoCmd.OpenReport "ReportPTMonth", acViewPreview, , "Month([DateOfTest]) =
"&
Me.ListMonths

BruceM said:
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.

Sylvie said:
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


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
 
S

Sylvie

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.

Douglas J. Steele said:
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!)


Sylvie said:
Private Sub ListMonths_Click()
DoCmd.OpenReport "ReportPTMonth", acViewPreview, , "Month([DateOfTest]) =
"&
Me.ListMonths

BruceM said:
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


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
 
D

Douglas J. Steele

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!)


Sylvie said:
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.

Douglas J. Steele said:
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!)


Sylvie said:
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


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
 
S

Sylvie

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!

Douglas J. Steele said:
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!)


Sylvie said:
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.

Douglas J. Steele said:
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


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
 
S

Sylvie

For the problem number 2 I find the error: The tables were one to many; I've
changed to ono to one and worked. TXS.

Sylvie said:
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!

Douglas J. Steele said:
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!)


Sylvie said:
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


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
 
B

BruceM

If you end the line of code after acViewPreview the report opens? Is
DateOfTest a date/time field? Try substituting a number for Me.ListMonths:
...."Month([DateOfTest]) = " & 6

If still no luck, try adding this before the DoCmd line of code:
Debug.Print Month([DateOfTest])
This will show you the value in the immediate window. If the code breaks
where it has in the past, look at the immediate window (it's labeled
"Immediate"; press Ctrl + G if you do not see it, as has been described).
Do you see a number there?
Alternatively you could do:
MsgBox Month([DateOfTest])


Sylvie said:
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!

Douglas J. Steele said:
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!)


Sylvie said:
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


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
 
D

Dirk Goldgar

Sylvie said:
There is the code:
Private Sub ListMonths_Click()
DoCmd.OpenReport "ReportPTMonth", acViewPreview, , "Month([DateOfTest]) =
"&
Me.ListMonths

End Sub


If I'm reading that correctly, and you copied and pasted the code, then you
are missing the required space between the closing quote and the ampersand.
 
S

Sylvie

Bruce,
DateofTest is a date/time, query has it as well as the report. Also I have
the expression to convert in mmm. So on the report is grouped by
expression:=Month([Expr1]). And the Expr1 is :Expr1:
Format([DateOfTEst],"mmmm/yyyy").
MAybe somewhere lays the dilemma.
When I did what you suggested of ending the code on acPreview it worked,
however when I click on July it showed all months. For the other options did
not work. TIA
BruceM said:
If you end the line of code after acViewPreview the report opens? Is
DateOfTest a date/time field? Try substituting a number for Me.ListMonths:
...."Month([DateOfTest]) = " & 6

If still no luck, try adding this before the DoCmd line of code:
Debug.Print Month([DateOfTest])
This will show you the value in the immediate window. If the code breaks
where it has in the past, look at the immediate window (it's labeled
"Immediate"; press Ctrl + G if you do not see it, as has been described).
Do you see a number there?
Alternatively you could do:
MsgBox Month([DateOfTest])


Sylvie said:
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!

Douglas J. Steele said:
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


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
 
B

BruceM

Month does not care about the format of the date. Just use
Month([DateOfTest]). The Month function can work on a string that Access
recognzes as a valid date, but November/2008 is not such a string. It could
well be the problem. It is also an important detail that you would have
done well to describe a while ago.

I don't know what you mean when you say you "click on July", but omitting
the two commas and:
"Month([DateOfTest]) = " & Me.ListMonths
means you are omitting what is called the Where condition. In other words
you are opening the report with all records. the idea was to see if the
report opens at all. It does. Now we know the problem is the Where
condition.


Sylvie said:
Bruce,
DateofTest is a date/time, query has it as well as the report. Also I have
the expression to convert in mmm. So on the report is grouped by
expression:=Month([Expr1]). And the Expr1 is :Expr1:
Format([DateOfTEst],"mmmm/yyyy").
MAybe somewhere lays the dilemma.
When I did what you suggested of ending the code on acPreview it worked,
however when I click on July it showed all months. For the other options
did
not work. TIA
BruceM said:
If you end the line of code after acViewPreview the report opens? Is
DateOfTest a date/time field? Try substituting a number for
Me.ListMonths:
...."Month([DateOfTest]) = " & 6

If still no luck, try adding this before the DoCmd line of code:
Debug.Print Month([DateOfTest])
This will show you the value in the immediate window. If the code breaks
where it has in the past, look at the immediate window (it's labeled
"Immediate"; press Ctrl + G if you do not see it, as has been described).
Do you see a number there?
Alternatively you could do:
MsgBox Month([DateOfTest])


Sylvie said:
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
 

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