PC Review


Reply
Thread Tools Rate Thread

Another DRW SQL statement - Access MDB

 
 
Mike Mueller
Guest
Posts: n/a
 
      27th Jan 2004
Thomas & Jon and all others who are more educated than I at this

I have succeeded at pulling the monthly information from an Access DB for my
home page. The next step is that I need to pull the next occurence and only
the next occurence for a particular event and place that in a results box.
Here is what I have so far and FP cannot verify this query:

SELECT TOP 1 MonthName([EventMonth],True)+" "+Str([EventDay]) AS Expr1
FROM Main
WHERE (((Main.EventDate)>=Date()) AND ((Main.EventDetail)="drill"))
ORDER BY Main.EventDate;


 
Reply With Quote
 
 
 
 
Jon Spivey
Guest
Posts: n/a
 
      28th Jan 2004
Hi Mike,

monthname wants the monthnumber (eg 1) not the whole date -

SELECT TOP 1 MonthName(Month(EventMonth),1)+' '+EventDay AS Expr1
FROM [Main]
WHERE EventDate >=Date() AND EventDetail='drill'
ORDER BY EventDate

I've also replaced double quotes with single - Access doesn't mind either
but it's not a good habit - if you move to another db (eg SQL Server) you'll
find you can't use double quotes. Think main is a reserved name too so I've
stuck it in [ ] to be on the safe side

Jon
Microsoft MVP - FP

"Mike Mueller" <(E-Mail Removed)> wrote in message
news:#DTj#(E-Mail Removed)...
> Thomas & Jon and all others who are more educated than I at this
>
> I have succeeded at pulling the monthly information from an Access DB for

my
> home page. The next step is that I need to pull the next occurence and

only
> the next occurence for a particular event and place that in a results box.
> Here is what I have so far and FP cannot verify this query:
>
> SELECT TOP 1 MonthName([EventMonth],True)+" "+Str([EventDay]) AS Expr1
> FROM Main
> WHERE (((Main.EventDate)>=Date()) AND ((Main.EventDetail)="drill"))
> ORDER BY Main.EventDate;
>
>



 
Reply With Quote
 
xmas
Guest
Posts: n/a
 
      28th Jan 2004
Hi Jon,

http://www.xmas-i-am.com/reserved_words.htm

I don't think Main is on the list...
But better to be safe than sorry....

xmas
=======================
"Jon Spivey" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
| Hi Mike,
|
| monthname wants the monthnumber (eg 1) not the whole date -
|
| SELECT TOP 1 MonthName(Month(EventMonth),1)+' '+EventDay AS Expr1
| FROM [Main]
| WHERE EventDate >=Date() AND EventDetail='drill'
| ORDER BY EventDate
|
| I've also replaced double quotes with single - Access doesn't mind either
| but it's not a good habit - if you move to another db (eg SQL Server)
you'll
| find you can't use double quotes. Think main is a reserved name too so
I've
| stuck it in [ ] to be on the safe side
|
| Jon
| Microsoft MVP - FP
|
| "Mike Mueller" <(E-Mail Removed)> wrote in message
| news:#DTj#(E-Mail Removed)...
| > Thomas & Jon and all others who are more educated than I at this
| >
| > I have succeeded at pulling the monthly information from an Access DB
for
| my
| > home page. The next step is that I need to pull the next occurence and
| only
| > the next occurence for a particular event and place that in a results
box.
| > Here is what I have so far and FP cannot verify this query:
| >
| > SELECT TOP 1 MonthName([EventMonth],True)+" "+Str([EventDay]) AS Expr1
| > FROM Main
| > WHERE (((Main.EventDate)>=Date()) AND ((Main.EventDetail)="drill"))
| > ORDER BY Main.EventDate;
| >
| >
|
|


 
Reply With Quote
 
Mike Mueller
Guest
Posts: n/a
 
      28th Jan 2004
Thank you Jon, but this will not verify either, here is a snip of the verify
error details:

[Microsoft][ODBC Microsoft Access Driver] Undefined function 'MonthName' in
expression.

I am going to try something different- I will let youknow the results

Mike


"Jon Spivey" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Mike,
>
> monthname wants the monthnumber (eg 1) not the whole date -
>
> SELECT TOP 1 MonthName(Month(EventMonth),1)+' '+EventDay AS Expr1
> FROM [Main]
> WHERE EventDate >=Date() AND EventDetail='drill'
> ORDER BY EventDate
>
> I've also replaced double quotes with single - Access doesn't mind either
> but it's not a good habit - if you move to another db (eg SQL Server)

you'll
> find you can't use double quotes. Think main is a reserved name too so

I've
> stuck it in [ ] to be on the safe side
>
> Jon
> Microsoft MVP - FP
>
> "Mike Mueller" <(E-Mail Removed)> wrote in message
> news:#DTj#(E-Mail Removed)...
> > Thomas & Jon and all others who are more educated than I at this
> >
> > I have succeeded at pulling the monthly information from an Access DB

for
> my
> > home page. The next step is that I need to pull the next occurence and

> only
> > the next occurence for a particular event and place that in a results

box.
> > Here is what I have so far and FP cannot verify this query:
> >
> > SELECT TOP 1 MonthName([EventMonth],True)+" "+Str([EventDay]) AS Expr1
> > FROM Main
> > WHERE (((Main.EventDate)>=Date()) AND ((Main.EventDetail)="drill"))
> > ORDER BY Main.EventDate;
> >
> >

>
>



 
Reply With Quote
 
Mike Mueller
Guest
Posts: n/a
 
      28th Jan 2004
Addendum-
I created a new field (EventOccur, text) and used an update query in
Access to do the monthname info. Then I created a NextDate query which just
would return the next event, and I am using this query for the DRW. Works
fine.

Mike


"Mike Mueller" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Thank you Jon, but this will not verify either, here is a snip of the

verify
> error details:
>
> [Microsoft][ODBC Microsoft Access Driver] Undefined function 'MonthName'

in
> expression.
>
> I am going to try something different- I will let youknow the results
>
> Mike
>
>
> "Jon Spivey" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi Mike,
> >
> > monthname wants the monthnumber (eg 1) not the whole date -
> >
> > SELECT TOP 1 MonthName(Month(EventMonth),1)+' '+EventDay AS Expr1
> > FROM [Main]
> > WHERE EventDate >=Date() AND EventDetail='drill'
> > ORDER BY EventDate
> >
> > I've also replaced double quotes with single - Access doesn't mind

either
> > but it's not a good habit - if you move to another db (eg SQL Server)

> you'll
> > find you can't use double quotes. Think main is a reserved name too so

> I've
> > stuck it in [ ] to be on the safe side
> >
> > Jon
> > Microsoft MVP - FP
> >
> > "Mike Mueller" <(E-Mail Removed)> wrote in message
> > news:#DTj#(E-Mail Removed)...
> > > Thomas & Jon and all others who are more educated than I at this
> > >
> > > I have succeeded at pulling the monthly information from an Access DB

> for
> > my
> > > home page. The next step is that I need to pull the next occurence

and
> > only
> > > the next occurence for a particular event and place that in a results

> box.
> > > Here is what I have so far and FP cannot verify this query:
> > >
> > > SELECT TOP 1 MonthName([EventMonth],True)+" "+Str([EventDay]) AS Expr1
> > > FROM Main
> > > WHERE (((Main.EventDate)>=Date()) AND ((Main.EventDetail)="drill"))
> > > ORDER BY Main.EventDate;
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting an Excel IF statement to an Access IFF statement =?Utf-8?B?cGFya3NqcDE=?= Microsoft Access 4 22nd Apr 2011 07:55 PM
in access, if then statement dtretina Microsoft Access Queries 2 7th Jun 2010 09:13 PM
How to use an IF Statement in Access =?Utf-8?B?Wg==?= Microsoft Access 2 28th Jul 2006 08:46 AM
How do I use a SQL statement in an MS Access data access page (HT. =?Utf-8?B?RG9uIE1pY2hhZWxz?= Microsoft Access 0 18th Jul 2006 09:30 PM
iif statement with And statement in query (ms access 2000) =?Utf-8?B?Sk0gS2VsbHk=?= Microsoft Access 1 14th Apr 2005 06:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:16 AM.