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  

too complex query



 
 
Thread Tools Display Modes
  #1  
Old January 15th, 2010, 03:19 PM posted to microsoft.public.access.queries
Barb
external usenet poster
 
Posts: 205
Default too complex query

hello
I'm using Access 2003 SP3 and here is my query based on single table

PARAMETERS StartDate DateTime, EndDate DateTime;
SELECT tblCalendarHistory.CalendarID, tblCalendarHistory.Date,
tblCalendarHistory.Division
FROM tblCalendarHistory
WHERE (((tblCalendarHistory.Date) Between "StartDate" And "EndDate") AND
((tblCalendarHistory.Division)=[Forms]![frmDivision]![txtDivision]));

At first I created a form for imputting start and End dates, but I was
getting "Too complex" message. So I created parameters - same message. If I
replace parameters with actual dates - then it works. I can't figure out what
can be too complex in this thing..

please help, I'd trully appreciate any ideas

Barb
  #2  
Old January 15th, 2010, 03:46 PM posted to microsoft.public.access.queries
Duane Hookom
external usenet poster
 
Posts: 7,177
Default too complex query

IMO parameter prompts are not good user interface. I think controls on forms
offer much more functionality.

Parameters must have [] not quotes. You might also want to add the
txtDivision to the parameters.

Try:
PARAMETERS [StartDate] DateTime, [EndDate] DateTime;
SELECT tblCalendarHistory.CalendarID, tblCalendarHistory.Date,
tblCalendarHistory.Division
FROM tblCalendarHistory
WHERE (((tblCalendarHistory.Date) Between [StartDate] And [EndDate') AND
((tblCalendarHistory.Division)=[Forms]![frmDivision]![txtDivision]));

--
Duane Hookom
Microsoft Access MVP


"Barb" wrote:

hello
I'm using Access 2003 SP3 and here is my query based on single table

PARAMETERS StartDate DateTime, EndDate DateTime;
SELECT tblCalendarHistory.CalendarID, tblCalendarHistory.Date,
tblCalendarHistory.Division
FROM tblCalendarHistory
WHERE (((tblCalendarHistory.Date) Between "StartDate" And "EndDate") AND
((tblCalendarHistory.Division)=[Forms]![frmDivision]![txtDivision]));

At first I created a form for imputting start and End dates, but I was
getting "Too complex" message. So I created parameters - same message. If I
replace parameters with actual dates - then it works. I can't figure out what
can be too complex in this thing..

please help, I'd trully appreciate any ideas

Barb

  #3  
Old January 15th, 2010, 04:36 PM posted to microsoft.public.access.queries
Barb
external usenet poster
 
Posts: 205
Default too complex query

Thank you Duane
You trully are a master.
[] worked - it's always the simple things that get you.

Could you help me more?
I agree it should be based on imput form, that was my original thought.
so, here is the same query tied to the form, again I'm getting "Too
complex'message

SELECT tblCalendarHistory.CalendarID, tblCalendarHistory.Date,
tblCalendarHistory.Division
FROM tblCalendarHistory
WHERE (((tblCalendarHistory.Date) Between
[Forms]![frmLocationsBookedNotServicedEntry]![txtStartDate] And
[Forms]![frmLocationsBookedNotServicedEntry]![txtEndDate]) AND
((tblCalendarHistory.Division)=[Forms]![frmDivision]![txtDivision]));

please and thank you

Barb

"Duane Hookom" wrote:

IMO parameter prompts are not good user interface. I think controls on forms
offer much more functionality.

Parameters must have [] not quotes. You might also want to add the
txtDivision to the parameters.

Try:
PARAMETERS [StartDate] DateTime, [EndDate] DateTime;
SELECT tblCalendarHistory.CalendarID, tblCalendarHistory.Date,
tblCalendarHistory.Division
FROM tblCalendarHistory
WHERE (((tblCalendarHistory.Date) Between [StartDate] And [EndDate') AND
((tblCalendarHistory.Division)=[Forms]![frmDivision]![txtDivision]));

--
Duane Hookom
Microsoft Access MVP


"Barb" wrote:

hello
I'm using Access 2003 SP3 and here is my query based on single table

PARAMETERS StartDate DateTime, EndDate DateTime;
SELECT tblCalendarHistory.CalendarID, tblCalendarHistory.Date,
tblCalendarHistory.Division
FROM tblCalendarHistory
WHERE (((tblCalendarHistory.Date) Between "StartDate" And "EndDate") AND
((tblCalendarHistory.Division)=[Forms]![frmDivision]![txtDivision]));

At first I created a form for imputting start and End dates, but I was
getting "Too complex" message. So I created parameters - same message. If I
replace parameters with actual dates - then it works. I can't figure out what
can be too complex in this thing..

please help, I'd trully appreciate any ideas

Barb

  #4  
Old January 15th, 2010, 06:56 PM posted to microsoft.public.access.queries
Dale Fye
external usenet poster
 
Posts: 2,651
Default too complex query

Barb,

You may still have to either declare the parameters, or explicitly type them
in the query. Try:

SELECT tblCalendarHistory.CalendarID,
tblCalendarHistory.Date,
tblCalendarHistory.Division
FROM tblCalendarHistory
WHERE tblCalendarHistory.Date
BETWEEN cDate([Forms]![frmLocationsBookedNotServicedEntry]![txtStartDate])
AND cDate([Forms]![frmLocationsBookedNotServicedEntry]![txtEndDate])
AND tblCalendarHistory.Division=[Forms]![frmDivision]![txtDivision]

HTH
Dale


"Barb" wrote in message
...
Thank you Duane
You trully are a master.
[] worked - it's always the simple things that get you.

Could you help me more?
I agree it should be based on imput form, that was my original thought.
so, here is the same query tied to the form, again I'm getting "Too
complex'message

SELECT tblCalendarHistory.CalendarID, tblCalendarHistory.Date,
tblCalendarHistory.Division
FROM tblCalendarHistory
WHERE (((tblCalendarHistory.Date) Between
[Forms]![frmLocationsBookedNotServicedEntry]![txtStartDate] And
[Forms]![frmLocationsBookedNotServicedEntry]![txtEndDate]) AND
((tblCalendarHistory.Division)=[Forms]![frmDivision]![txtDivision]));

please and thank you

Barb

"Duane Hookom" wrote:

IMO parameter prompts are not good user interface. I think controls on
forms
offer much more functionality.

Parameters must have [] not quotes. You might also want to add the
txtDivision to the parameters.

Try:
PARAMETERS [StartDate] DateTime, [EndDate] DateTime;
SELECT tblCalendarHistory.CalendarID, tblCalendarHistory.Date,
tblCalendarHistory.Division
FROM tblCalendarHistory
WHERE (((tblCalendarHistory.Date) Between [StartDate] And [EndDate') AND
((tblCalendarHistory.Division)=[Forms]![frmDivision]![txtDivision]));

--
Duane Hookom
Microsoft Access MVP


"Barb" wrote:

hello
I'm using Access 2003 SP3 and here is my query based on single table

PARAMETERS StartDate DateTime, EndDate DateTime;
SELECT tblCalendarHistory.CalendarID, tblCalendarHistory.Date,
tblCalendarHistory.Division
FROM tblCalendarHistory
WHERE (((tblCalendarHistory.Date) Between "StartDate" And "EndDate")
AND
((tblCalendarHistory.Division)=[Forms]![frmDivision]![txtDivision]));

At first I created a form for imputting start and End dates, but I was
getting "Too complex" message. So I created parameters - same message.
If I
replace parameters with actual dates - then it works. I can't figure
out what
can be too complex in this thing..

please help, I'd trully appreciate any ideas

Barb



  #5  
Old January 15th, 2010, 08:10 PM posted to microsoft.public.access.queries
Barb
external usenet poster
 
Posts: 205
Default too complex query

Thank you Dale
It worked perfectly

Barb

"Dale Fye" wrote:

Barb,

You may still have to either declare the parameters, or explicitly type them
in the query. Try:

SELECT tblCalendarHistory.CalendarID,
tblCalendarHistory.Date,
tblCalendarHistory.Division
FROM tblCalendarHistory
WHERE tblCalendarHistory.Date
BETWEEN cDate([Forms]![frmLocationsBookedNotServicedEntry]![txtStartDate])
AND cDate([Forms]![frmLocationsBookedNotServicedEntry]![txtEndDate])
AND tblCalendarHistory.Division=[Forms]![frmDivision]![txtDivision]

HTH
Dale


"Barb" wrote in message
...
Thank you Duane
You trully are a master.
[] worked - it's always the simple things that get you.

Could you help me more?
I agree it should be based on imput form, that was my original thought.
so, here is the same query tied to the form, again I'm getting "Too
complex'message

SELECT tblCalendarHistory.CalendarID, tblCalendarHistory.Date,
tblCalendarHistory.Division
FROM tblCalendarHistory
WHERE (((tblCalendarHistory.Date) Between
[Forms]![frmLocationsBookedNotServicedEntry]![txtStartDate] And
[Forms]![frmLocationsBookedNotServicedEntry]![txtEndDate]) AND
((tblCalendarHistory.Division)=[Forms]![frmDivision]![txtDivision]));

please and thank you

Barb

"Duane Hookom" wrote:

IMO parameter prompts are not good user interface. I think controls on
forms
offer much more functionality.

Parameters must have [] not quotes. You might also want to add the
txtDivision to the parameters.

Try:
PARAMETERS [StartDate] DateTime, [EndDate] DateTime;
SELECT tblCalendarHistory.CalendarID, tblCalendarHistory.Date,
tblCalendarHistory.Division
FROM tblCalendarHistory
WHERE (((tblCalendarHistory.Date) Between [StartDate] And [EndDate') AND
((tblCalendarHistory.Division)=[Forms]![frmDivision]![txtDivision]));

--
Duane Hookom
Microsoft Access MVP


"Barb" wrote:

hello
I'm using Access 2003 SP3 and here is my query based on single table

PARAMETERS StartDate DateTime, EndDate DateTime;
SELECT tblCalendarHistory.CalendarID, tblCalendarHistory.Date,
tblCalendarHistory.Division
FROM tblCalendarHistory
WHERE (((tblCalendarHistory.Date) Between "StartDate" And "EndDate")
AND
((tblCalendarHistory.Division)=[Forms]![frmDivision]![txtDivision]));

At first I created a form for imputting start and End dates, but I was
getting "Too complex" message. So I created parameters - same message.
If I
replace parameters with actual dates - then it works. I can't figure
out what
can be too complex in this thing..

please help, I'd trully appreciate any ideas

Barb



.

  #6  
Old January 16th, 2010, 01:01 AM posted to microsoft.public.access.queries
Allen Browne
external usenet poster
 
Posts: 11,706
Default too complex query

The problem is twofold:

a) You used quotes instead of square brackets around your parameter names,
so Access is trying to compare a date to the literal text "StartDate" which
doesn't compute.

b) You have a reserved word (Date) as a field name. You can try adding
square brackets around the bad name, but a better solution would be to
rename the field.

Try:
WHERE tblCalendarHistory.[Date] Between [StartDate] And [EndDate]

For a list of names to avoid when adding fields to your tables, see:
http://allenbrowne.com/Ap****ueBadWord.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"Barb" wrote in message
...
hello
I'm using Access 2003 SP3 and here is my query based on single table

PARAMETERS StartDate DateTime, EndDate DateTime;
SELECT tblCalendarHistory.CalendarID, tblCalendarHistory.Date,
tblCalendarHistory.Division
FROM tblCalendarHistory
WHERE (((tblCalendarHistory.Date) Between "StartDate" And "EndDate") AND
((tblCalendarHistory.Division)=[Forms]![frmDivision]![txtDivision]));

At first I created a form for imputting start and End dates, but I was
getting "Too complex" message. So I created parameters - same message.
If I replace parameters with actual dates - then it works. I can't figure
out
what can be too complex in this thing..



 




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 05:34 PM.


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