cannot use criteria on query (1 Viewer)

mp0u8015

New member
Local time
Today, 18:54
Joined
Oct 26, 2010
Messages
9
I have a database query that is very simple with 7 columns from a linked table. The columns are for example

Customer/Invoice ref/invoice date/description/net value/vat/gross value

the problem i have is that tehre must be approximately 500,000+ rows in the query.

I want to show only those items from 2010, however when I put in a criteria such as DATE = 2010 I get the message "ODBC--Call failed [microsoft][ODBC SQL Server Driver] timeout expired (#0).

Im guessing this is due to the size of the query and the sorting necessary.

Does anyone have any idea as to how I could resolve this?

Thanks in advance...
 

DCrake

Remembered
Local time
Today, 18:54
Joined
Jun 8, 2005
Messages
8,632
Create another column in your query

YearDate:Year([Date])


and filter on that column
 

Brianwarnock

Retired
Local time
Today, 18:54
Joined
Jun 2, 2003
Messages
12,701
Create another column in your query

YearDate:Year([Date])


and filter on that column

I take it you mean
YearDate:Year([Invoice Date])

else you would be telling the poster not to use Date as a field name, I should add that spaces are best avoided too, use _ instead

Brian
 

DCrake

Remembered
Local time
Today, 18:54
Joined
Jun 8, 2005
Messages
8,632
Its been a long day, you were right Brian I should have specified Invoice Date.;)
 

mp0u8015

New member
Local time
Today, 18:54
Joined
Oct 26, 2010
Messages
9
i have tried this already and it fell down. I also tried a second table with one column YEAR and one row 2010. tried to link this and again it broke down....
 

Brianwarnock

Retired
Local time
Today, 18:54
Joined
Jun 2, 2003
Messages
12,701
Question Is Sql Server involved here, if so I probably can't help and you may get a better response by posting in that forum.

Brian
 

mp0u8015

New member
Local time
Today, 18:54
Joined
Oct 26, 2010
Messages
9
Question Is Sql Server involved here, if so I probably can't help and you may get a better response by posting in that forum.

Brian


Hi Brian yes it is. How very annoying. is there any way to tranfer the post to that forum?
 

boblarson

Smeghead
Local time
Today, 10:54
Joined
Jan 12, 2001
Messages
32,059
is there any way to tranfer the post to that forum?

Yes, I can move it.

One quick question - you didn't provide the SQL for your query as Brian had asked. Can you do so?

Also, do your SQL Tables all have primary keys defined? Are you using any VIEWS here in the query?
 

Brianwarnock

Retired
Local time
Today, 18:54
Joined
Jun 2, 2003
Messages
12,701
I didn't give him time to post the SQL before the penny dropped that it was SQL Server of which I have no experience but have noticed that certain things such as Date - Getdate are different. However I'm sure it will be useful to people who can help.

Brian
 

boblarson

Smeghead
Local time
Today, 10:54
Joined
Jan 12, 2001
Messages
32,059
I didn't give him time to post the SQL before the penny dropped that it was SQL Server of which I have no experience but have noticed that certain things such as Date - Getdate are different. However I'm sure it will be useful to people who can help.

Brian
I have SQL Server experience but hopefully having the SQL will help.

Also, mp0u8015 - Where are you building this query? Is it in Access or is it a VIEW in SQL Server? WHERE you are doing this is a key piece of information as well as WHAT the SQL is as they are intertwined.
 

mp0u8015

New member
Local time
Today, 18:54
Joined
Oct 26, 2010
Messages
9
I have SQL Server experience but hopefully having the SQL will help.

Also, mp0u8015 - Where are you building this query? Is it in Access or is it a VIEW in SQL Server? WHERE you are doing this is a key piece of information as well as WHAT the SQL is as they are intertwined.

SQL is

SELECT dbo_ORD_DETAIL.OD_ACCOUNT, dbo_ORD_DETAIL.OD_ORDER_NUMBER, dbo_ORD_DETAIL.OD_DATE, dbo_ORD_DETAIL.OD_STOCK_CODE, dbo_ORD_DETAIL.OD_DETAIL, dbo_ORD_DETAIL.OD_NETT
FROM dbo_ORD_DETAIL;


it is a simple query by choosing the columns from the query in design mode in access
 

boblarson

Smeghead
Local time
Today, 10:54
Joined
Jan 12, 2001
Messages
32,059
So does dbo_ORD_DETAIL have a primary key with index set?
 

boblarson

Smeghead
Local time
Today, 10:54
Joined
Jan 12, 2001
Messages
32,059
No, how do i set these after bringing in the table?
What do you mean after you bring them in? You are LINKING to the SQL Server tables aren't you? And that means you need to have them set in the actual table in SQL SERVER, not AFTER you connect to them in Access.
 

mp0u8015

New member
Local time
Today, 18:54
Joined
Oct 26, 2010
Messages
9
Sorry, as you can see im quite new to access and am mixing up with importing the table where it asks to define a primary key.

The answer therefore is I dont know if a primary key with an index set. What should I do from here?
 

boblarson

Smeghead
Local time
Today, 10:54
Joined
Jan 12, 2001
Messages
32,059
Sorry, as you can see im quite new to access and am mixing up with importing the table where it asks to define a primary key.

The answer therefore is I dont know if a primary key with an index set. What should I do from here?

Who's responsible for maintaining the SQL Server database? Ask them if there is a primary key and indexing on the table(s). If not, then ask them if they can add those as you are having issues because of the lack thereof.
 

boblarson

Smeghead
Local time
Today, 10:54
Joined
Jan 12, 2001
Messages
32,059
Sorry, as you can see im quite new to access and am mixing up with importing the table where it asks to define a primary key.
If it asks you to define which field is a primary key then it likely doesn't have one set.
 

Brianwarnock

Retired
Local time
Today, 18:54
Joined
Jun 2, 2003
Messages
12,701
Ok as I said earlier i no nothing about SQL Server and i only came back out of curiosity, but the title of the thread is about criteria, so why is there no Where clause.

Sorry to be so ignorant.

Brian
 

Users who are viewing this thread

Top Bottom