A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

My Eyes Are Crossing



 
 
Thread Tools Display Modes
  #1  
Old January 8th, 2007, 10:16 PM posted to microsoft.public.access.queries
Gwen H
external usenet poster
 
Posts: 33
Default My Eyes Are Crossing

I have a query that is selecting no records, and I can't figure out why. It
involves two tables, "activities" and "activitiesABM_Temp". I want the query
to take the temp table and find related records in the activities table,
based on a loan officer number AND the last day of the previous month. This
query is run each month, so the date restrictor needs to always look for the
last day of the previous month. I know there's something wrong with the date
restrictor, because when I remove it the query works. But I can't for the
life of me figure out why. This is part of a large database project that I've
just been working on for too long.

SELECT activities.deposits
FROM activitiesABM_TEMP LEFT JOIN activities ON
activitiesABM_TEMP.assistantManager = activities.officerNumber
WHERE
(((activities.officerNumber)=([activitiesABM_TEMP].[assistantManager])) AND
((activities.month)=DateSerial(Year(Date()),Month( Date()),0)));

Ideas and suggestions are greatly appreciated!
Many thanks,

--
GwenH, CIW, CWP, Master MOS
Some of my best leading men have been dogs and horses ~ Elizabeth Taylor
  #2  
Old January 8th, 2007, 10:36 PM posted to microsoft.public.access.queries
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default My Eyes Are Crossing

What does activities.month contain: an actual date, or something else? (BTW,
Month is a bad choice for a field name: it's a reserved word, and using
reserved words for your own purposes can lead to problems. If you cannot, or
will not, change the field name, at least enclose it in square brackets)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Gwen H" wrote in message
...
I have a query that is selecting no records, and I can't figure out why. It
involves two tables, "activities" and "activitiesABM_Temp". I want the
query
to take the temp table and find related records in the activities table,
based on a loan officer number AND the last day of the previous month.
This
query is run each month, so the date restrictor needs to always look for
the
last day of the previous month. I know there's something wrong with the
date
restrictor, because when I remove it the query works. But I can't for the
life of me figure out why. This is part of a large database project that
I've
just been working on for too long.

SELECT activities.deposits
FROM activitiesABM_TEMP LEFT JOIN activities ON
activitiesABM_TEMP.assistantManager = activities.officerNumber
WHERE
(((activities.officerNumber)=([activitiesABM_TEMP].[assistantManager]))
AND
((activities.month)=DateSerial(Year(Date()),Month( Date()),0)));

Ideas and suggestions are greatly appreciated!
Many thanks,

--
GwenH, CIW, CWP, Master MOS
Some of my best leading men have been dogs and horses ~ Elizabeth Taylor



  #3  
Old January 9th, 2007, 12:25 AM posted to microsoft.public.access.queries
Gwen H
external usenet poster
 
Posts: 33
Default My Eyes Are Crossing

Activities.month contains a date - always the last day of a given month.
--
GwenH, CIW, CWP, Master MOS
Some of my best leading men have been dogs and horses ~ Elizabeth Taylor


"Douglas J. Steele" wrote:

What does activities.month contain: an actual date, or something else? (BTW,
Month is a bad choice for a field name: it's a reserved word, and using
reserved words for your own purposes can lead to problems. If you cannot, or
will not, change the field name, at least enclose it in square brackets)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Gwen H" wrote in message
...
I have a query that is selecting no records, and I can't figure out why. It
involves two tables, "activities" and "activitiesABM_Temp". I want the
query
to take the temp table and find related records in the activities table,
based on a loan officer number AND the last day of the previous month.
This
query is run each month, so the date restrictor needs to always look for
the
last day of the previous month. I know there's something wrong with the
date
restrictor, because when I remove it the query works. But I can't for the
life of me figure out why. This is part of a large database project that
I've
just been working on for too long.

SELECT activities.deposits
FROM activitiesABM_TEMP LEFT JOIN activities ON
activitiesABM_TEMP.assistantManager = activities.officerNumber
WHERE
(((activities.officerNumber)=([activitiesABM_TEMP].[assistantManager]))
AND
((activities.month)=DateSerial(Year(Date()),Month( Date()),0)));

Ideas and suggestions are greatly appreciated!
Many thanks,

--
GwenH, CIW, CWP, Master MOS
Some of my best leading men have been dogs and horses ~ Elizabeth Taylor




  #4  
Old January 9th, 2007, 01:13 AM posted to microsoft.public.access.queries
Van T. Dinh
external usenet poster
 
Posts: 1,048
Default My Eyes Are Crossing

AFAICS (and I may be wrong):

1. The first criterion is not needed as this is already covered by the On
Clause.

2. In this Query, the INNER JOIN should give you the same result except the
INNER JOIN will be more efficient.

3. Have you checked the values of the Field [month] and make sure that the
values have zero time component? Your SQL won't work correctly if the
values of [month] in Table [activities] have non-zero time component.

If_all_ time component values are zero, try:

========
SELECT activities.deposits
FROM activities INNER JOIN activitiesABM_TEMP
ON activities.officerNumber = activitiesABM_TEMP.assistantManager
WHERE (activities.[month] = DateSerial(Year(Date()), Month(Date()), 0));
========

--
HTH
Van T. Dinh
MVP (Access)



"Gwen H" wrote in message
...
Activities.month contains a date - always the last day of a given month.
--
GwenH, CIW, CWP, Master MOS
Some of my best leading men have been dogs and horses ~ Elizabeth Taylor



 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:39 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.