Re: Sort by Month/Year

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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



Relevant Pages

  • Re: [VisualAge] Long lists in Client/Server application
    ... I would be able to ask the cursor to ... if it IS a database ... should switch over now to see if I have the same issue on PostgreSQL. ... query, but I can't see any easy way to position the the cursor at the ...
    (comp.lang.smalltalk)
  • Re: Populating a Pull-Down
    ... you are also forcing ADO to make a second trip to the database ... Why open a less-efficient static cursor? ... I'm surprised you are not getting an error from "User Query". ... This line is not necessary, and in fact, may cause the recordset to be ...
    (microsoft.public.scripting.vbscript)
  • Re: MSforeachdb question
    ... Could you use a cursor to iterate through the databases. ... following code to query the databases and put the data into a temporary ... DECLARE cDataBases CURSOR ... WHERE name like 'ABC%' -- you may want to filter some database names ...
    (microsoft.public.sqlserver.server)
  • Re: Truncated Memo field displayed on form
    ... 255 characters in any column that is in the combo box's RowSource query. ... My fields down to "Knowledge and Understandings" are fine. ... occurs with the "descriptor" field being truncated on my form. ...
    (microsoft.public.access.forms)
  • Re: database persistence with mysql, sqlite
    ... records without reestablishing a database connection every time I ... left from the initial query. ... open cursor can lock-out writers, ... mod_python (Python Server Pages under Apache). ...
    (comp.lang.python)