Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date query using VB code in Access

Status
Not open for further replies.

mickeyuk

IS-IT--Management
Sep 24, 2004
25
GB
I am trying to run a query that when you click on it, it shows any due dates for inspections test to appear for the month your in. E.g. I want to know all the inspections tests that are due in June. I have the following code but it doesn’t seem to work. It will show some of the tests due but not all of them.

Here’s the code:

Code:
SELECT [tblemployee Details].Department, [tblemployee Details].[Payroll No], [tblemployee Details].[First Name], [tblemployee Details].ADateDue, [tblemployee Details].LDateDue, [tblemployee Details].CDateDue, [tblemployee Details].CCDateDue, [tblemployee Details].SDateDue, [tblemployee Details].HDateDue, [tblemployee Details].MDateDue, [tblemployee Details].RDateDue
FROM [tblemployee Details]
WHERE (((Month([tblemployee Details].[LDate Due]))=Month(Now()))) OR (((Month([tblemployee Details].[LDate Due])=Month(Now()))=True))
ORDER BY [tblemployee Details].Department;

Thanks

Michelle
 
Does this relate to VBA programming - or is it a query question (forum701)?

If the first, I'd expected to see some code, i e the context where this is run, how you've concatenated the string - and something more than "doesn't work" - error number/message, what happens, what should happen... more info on how to get the best answers can be found in faq181-2886

Roy-Vidar
 
I note that the field LDateDue appears without a space in the SELECT part of the statement but with with an embedded space (i.e. [LDate[COLOR=red yellow] [/color] Due]) in the WHERE clause. Also the WHERE clause seems to have redundant conditions. Try something like
Code:
SELECT E.Department, E.[Payroll No], E.[First Name],
       E.ADateDue, E.LDateDue, E.CDateDue, E.CCDateDue,
       E.SDateDue, E.HDateDue, E.MDateDue, E.RDateDue

FROM [tblemployee Details] E

WHERE Month(E.[LDateDue])=Month(Now()) 

ORDER BY E.Department;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top