Re: Sort by Month/Year
- From: "'69 Camaro" <ForwardZERO_SPAM.To.69Camaro@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 6 Oct 2005 11:28:43 -0700
Did you copy the text from from the Web page? You may have copied
"invisible" characters when you pasted them into the query. Try moving the
cursor to the very end of the line after the semicolon and then press the
<END> key on your keyboard. Does the cursor jump somewhere else? If not,
then move the cursor down a line and press the <END> key again. Does it jump
somewhere else? If not, check every "blank" line after the line with the
semicolon to see if there's any invisible invisible characters.
If you don't find anything, but Jet is reading something there, then that's
an indication of database file corruption. First, create a backup of your
database, then do a compact/repair.
Next, create an entirely new query. When you are at the QBE grid again,
select the View -> SQL -> SQL View to open the SQL View pane again. Type
(don't paste) the SQL statement into the new query:
SELECT EvalDate
FROM tblMain
ORDER BY Year(EvalDate), Month(EvalDate);
.. . . and then run the query. Do you have any further problems?
HTH.
Gunny
See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
"RTimberlake" wrote:
> Here is the code:
> SELECT EvalDate
> FROM tblMain
> ORDER BY Year(EvalDate), Month(EvalDate);
> I am still getting the same popup: "Characters found at end of SQL
> statement." But, There is nothing at the end of the statement. What is going
> on?
>
> --RT
>
> "'69 Camaro" wrote:
>
> > Your query is missing something, too. Like where does the Expr1 table name
> > come from? And you'll have trouble if you try to code something that uses a
> > Reserved word for the name. For example, Date is a Reserved word because it
> > is the name of a VBA function. You should rename the Date field in your
> > table to something meaningful, such as OrderDate. After you make the change
> > and save the table and then close it, come back to this query and change it
> > to:
> >
> > SELECT OrderDate
> > FROM tblMain
> > ORDER BY Year(OrderDate), Month(OrderDate);
> >
> > . . . and replace OrderDate in my example with the new name you gave yours.
> > Ensure that there are no characters after that final semicolon on the last
> > line.
> >
> > HTH.
> > Gunny
> >
> > See http://www.QBuilt.com for all your database needs.
> > See http://www.Access.QBuilt.com for Microsoft Access tips.
> >
> > (Please remove ZERO_SPAM from my reply E-mail address so that a message will
> > be forwarded to me.)
> > - - -
> > If my answer has helped you, please sign in and answer yes to the question
> > "Did this post answer your question?" at the bottom of the message, which
> > adds your question and the answers to the database of answers. Remember that
> > questions answered the quickest are often from those who have a history of
> > rewarding the contributors who have taken the time to answer questions
> > correctly.
> >
> >
> > "RTimberlake" wrote:
> >
> > > This is what it said...
> > > SELECT Expr1.Date FROM tblMain ORDER BY Year(Date), Month(Date);
> > >
> > > When I tried to close the window it says...
> > > Characters found at end of SQL statement.
> > >
> > > "'69 Camaro" wrote:
> > >
> > > > You were using the QBE (Query By Example) grid to create a query. This
> > > > automatically creates the SQL statement that Jet reads and executes to
> > > > "query the database." To view this SQL statement, select the View -> SQL
> > > > View menu and text will appear in a white window. That text is the SQL
> > > > statement. Please copy that text in its entirety and paste it into your
> > > > next message.
> > > >
> > > > HTH.
> > > > Gunny
> > > >
> > > > See http://www.QBuilt.com for all your database needs.
> > > > See http://www.Access.QBuilt.com for Microsoft Access tips.
> > > >
> > > >
> > > > "RTimberlake" <RTimberlake@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > > > news:DA0CBA21-CC75-4EA7-B712-7CB8D9387123@xxxxxxxxxxxxxxxx
> > > > >I don't have an SQL statement. I was doing it in a query.
> > > > >
> > > > >
> > > > > "'69 Camaro" wrote:
> > > > >
> > > > >> Please post your SQL statement here, and we'll take a look at it.
> > > > >>
> > > > >> HTH.
> > > > >> Gunny
> > > > >>
> > > > >> See http://www.QBuilt.com for all your database needs.
> > > > >> See http://www.Access.QBuilt.com for Microsoft Access tips.
> > > > >>
> > > > >>
> > > > >> "RTimberlake" <RTimberlake@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > > > >> news:60024FC9-0185-4DD8-A737-3FD853FEACB4@xxxxxxxxxxxxxxxx
> > > > >> > When I tried what you said I get a message that says Invalid Syntax.
> > > > >> > How
> > > > >> > can
> > > > >> > I fix it?
> > > > >> >
> > > > >> > "'69 Camaro" wrote:
> > > > >> >
> > > > >> >> Hi.
> > > > >> >>
> > > > >> >> Try:
> > > > >> >>
> > > > >> >> SELECT OrderID, SalesDate
> > > > >> >> FROM tblSales
> > > > >> >> ORDER BY Year(SalesDate), Month(SalesDate);
> > > > >> >>
> > > > >> >> . . . where tblSales is the name of the table and SalesDate is the
> > > > >> >> name
> > > > >> >> of
> > > > >> >> the field containing the date to be sorted, first by year, then by
> > > > >> >> month.
> > > > >> >> However, if you want to sort by month, and then by year, try:
> > > > >> >>
> > > > >> >> SELECT OrderID, SalesDate
> > > > >> >> FROM tblSales
> > > > >> >> ORDER BY Month(SalesDate), Year(SalesDate);
> > > > >> >>
> > > > >> >> HTH.
> > > > >> >> Gunny
> > > > >> >>
> > > > >> >> See http://www.QBuilt.com for all your database needs.
> > > > >> >> See http://www.Access.QBuilt.com for Microsoft Access tips.
> > > > >> >>
> > > > >> >> (Please remove ZERO_SPAM from my reply E-mail address so that a
> > > > >> >> message
> > > > >> >> will
> > > > >> >> be forwarded to me.)
> > > > >> >> - - -
> > > > >> >> If my answer has helped you, please sign in and answer yes to the
> > > > >> >> question
> > > > >> >> "Did this post answer your question?" at the bottom of the message,
> > > > >> >> which
> > > > >> >> adds your question and the answers to the database of answers.
> > > > >> >> Remember
> > > > >> >> that
> > > > >> >> questions answered the quickest are often from those who have a
> > > > >> >> history
> > > > >> >> of
> > > > >> >> rewarding the contributors who have taken the time to answer questions
> > > > >> >> correctly.
> > > > >> >>
> > > > >> >>
> > > > >> >> "RTimberlake" wrote:
> > > > >> >>
> > > > >> >> > I have a date feild that fills mm/dd/yyyy
> > > > >> >> > Is there a way to sort by just month and year?
> > > > >>
> > > > >>
> > > > >>
> > > >
> > > >
> > > >
.
- References:
- Re: Sort by Month/Year
- From: RTimberlake
- Re: Sort by Month/Year
- Prev by Date: Re: Sort by Month/Year
- Next by Date: Re: Cross Tab Query & Dates
- Previous by thread: Re: Sort by Month/Year
- Next by thread: Re: Adding numbers from Different Tables
- Index(es):
Relevant Pages
|