Queries :: Slow Query Filtering On Concatenated Variable

Jul 9, 2015

I am trying to use a criteria to filter out nulls in concatenated variable, which slows the query considerably.The part that makes it slow looks like this -

WHERE ... AND (([tbl1].[x] & [tbl1].[y]) <> "") AND ...

If I work them individually, it's not a problem, the query is fast, but I have to combine them first in order to produce the correct output.

View Replies


ADVERTISEMENT

Slow Query Using A Global Variable

Aug 9, 2005

Hello,

I have the following query that I set up as a test, and it runs fine:

SELECT STATUSHISTORIE.*
FROM STATUSHISTORIE LEFT JOIN PROBLEM_DE ON STATUSHISTORIE.PROBLEM_ID = PROBLEM_DE.PROBLEMNR
WHERE (((STATUSHISTORIE.STATUSDATUM)<#1/1/2005#) AND ((PROBLEM_DE.DATENBEREICH)='SPMO') AND (((Left(([PROBLEM_DE].[MODULZUORDNUNG]),InStr([PROBLEM_DE].[MODULZUORDNUNG],"-")-2)))='K29') AND ((PROBLEM_DE.ERLSTAND)<>"WEIF"))
ORDER BY STATUSHISTORIE.PROBLEM_ID,
STATUSHISTORIE.STATUSDATUM;

I then set up two global variables ( a String and a Date) and respective functions to return them – ReturnE( ) and ReturnKW( ). Now my query looks like this, but takes ages to run:

SELECT STATUSHISTORIE.*
FROM STATUSHISTORIE LEFT JOIN PROBLEM_DE ON [STATUSHISTORIE].[PROBLEM_ID]=[ PROBLEM_DE].[PROBLEMNR]
WHERE (((STATUSHISTORIE.STATUSDATUM)<ReturnKW( ) ) AND ((PROBLEM_DE.DATENBEREICH)='SPMO') AND (((Left(([PROBLEM_DE].[MODULZUORDNUNG]),InStr([PROBLEM_DE].[MODULZUORDNUNG],"-")-2)))=ReturnE( ) ) AND ((PROBLEM_DE.ERLSTAND)<>"WEIF"))
ORDER BY [STATUSHISTORIE].[PROBLEM_ID], [STATUSHISTORIE].[STATUSDATUM];

My two public functions that return the global variables look like this:

Public gstrE As String 'global variable: contains E used for query
Public gdatKW As Date

Public Function ReturnE ()
ReturnE = gstrE
End Function

Public Function ReturnKW ()
ReturnKW = gdatKW
End Function


The tables are actually Views set up from an ODBC Data source. Can anyone please tell me why these global variables are causing the traffic jam? :)

Thanks in advance
J

View 6 Replies View Related

Queries :: Pass Through Query Slow Until Change Search Criteria

May 21, 2014

I have an access 2007 database connect to sql server 2008.I am running a pass though query to search between two dates (this query has been fine for years)

If I now run any search using parameters from 26th March 2014 to date - the query takes 10+ minutes to run.If I then change the date to 25th March 2014 to date - it runs in a nano second.I have not changed the back tables and I have not changed the format the data is saved in.

View 2 Replies View Related

Filtering Using Variable Parameter

May 28, 2012

Using the following filter works fine

Student.Filter = "[Class ID]= 270"

But when replaced by the following it does not work:

p = 270

Student.Filter = "[Class ID]= p"

The error message is: 3061 "Too few parameters. Expected 2.

These codes look identical I wonder why the second one doesn't work.

View 3 Replies View Related

Queries :: Soft Coded Date Filter Causing Query To Run Slow

Jan 2, 2015

created a query (in Access 2010) that joins several linked tables (to an Oracle database). The query runs in about 20 seconds when I filter with a hard coded date (e.g., #12/31/2014#). The Oracle table column Im filtering on is defined as date/time.

When I attempt to change the hard coded value to a soft coded value (e.g., Forms![Form1]![Latest_Extract_Date]), the query runs over 5 minutes. In this case, the form field has the exact same value (12/31/2014).

Ive encountered similar issues using Access 2000, 2003, etc. This is quite frustrating. Does Access interpret #date value# is a special way? Is there a way to trick Access into the thinking a soft coded date is a hard coded date?

View 1 Replies View Related

Queries :: Multi Concatenated Text Box To Individual Row

Sep 30, 2014

I have imported a lot of data from excel into a table. There is in one of the columns some multi concatenate info I want to separate in it's own individual row.I am not sure if there is a way to do this in a query or if there was an MsAccess2007 example somewhere. I looked on the internet but couldn't find anything.

the columns are like this now

123456 7RFE01, 7RFE03, 7MFE06, 7MFH04
237890 8RFE80, 8MFE03, 9GFE06, 5QFH06, 3QFY06

I want the columns to be like this in a query or new table.

123456 7RFE01
123456 7RFE03
123456 7MFE06
123456 7MFH04
237890 8RFE80
237890 8MFE03
237890 9GFE06
237890 5QFH06
237890 3QFY06

View 5 Replies View Related

Make Table Queries And Concatenated Memo Fields

Jul 13, 2006

I have a Make Table query that includes a new field concatenated from a numeric field and a memo field, with some assorted text elements -
Issue Description:"("&[number]&") "&[Description]

When I run the Make Table, the new field "Issue Description" is created as a text field, NOT as a memo field.

Is there any way to insure that this field is created as a memo field.

Thanks.

Susan

View 1 Replies View Related

Concatenated Query Help

Nov 5, 2004

I have built a query, a series of concatentions. What I need to do is add this query as a field on my form. So that the info that has been concatenated is stored in my table. Can this be done? I am able to show this query field on a report, but I need to pull the concatented info into the table. Hopefully I have explained this well enough.

Sincerely,
Tasha

View 5 Replies View Related

Queries :: How To Specify A Variable In A Query

Aug 18, 2013

I have a query that has three fields: 1) Days 2) Bit Size 3) Feet. The Days field has a date range specified in the Criteria that comes from two unbound fields on a form. I have a second query based on the first: Two fields are Days with the Total as Min and Max. Three fields are Feet with the Total as Min, Mac, Avg. One field is Bit Size with the Criteria as a specified bit size (i.e. 6.125). These queries are used on a report, and all data is inputted from forms prior to the report.

The queries work as expected with a specified bit size. My problem is that while Bit Size is normally chosen from a list of sizes, a custom size can be inputted. I am unsure how I can specify the Criteria in Bit Size to be a custom size..? To compound things further, more than one custom size can be used.

A) I need a way to pick out the custom sizes from the first query and B) use them as the Criteria for the second query. If I use VBA, I assume I could complete B) by using a WHERE clause (if the custom size(s) has been defined)...

View 6 Replies View Related

Query Is Re-organizing Data In A Concatenated String

Jan 11, 2012

I'm putting together a shipping database. We scan in a string of barcodes, separate out the Serial Numbers from the Barcode Data, concatenate them together as a string with asterisks as a delimiter and join them together with a date code and manufacturing line identifier. Throughout all of the data manipulations I am able to maintain the Serial Numbers in my table in the order which they were scanned in. The very last function is to concatenate the Serial Numbers and Lot information together into one long string which will then be output to a label creation software. And up to that point, the Serial Numbers are still in the correct order (based on them being linked to an autonumber field in the initial table) Upon the final concatenation, the order of the Serial Numbers is being changed, sometimes 17 out of 18 Serial Numbers will be correctly ordered with just one being randomly placed in the string out of order. Here is the code in SQL that I use for concatenating.

INSERT INTO tempMotorPalletLabel ( PalletLabel )
SELECT DISTINCT tempMotors_to_Warehouse.PalletNumber&"*"&tempMotor s_to_Warehouse.Count&"*"&tempMotors_to_Warehouse.P artNumber + '*' + Replace(Replace(ConcatRelated("SerialNumber","temp Motors_to_Warehouse","PalletNumber='"&PalletNumber &"'"),' ',''),',','*')
FROM tempMotors_to_Warehouse;

And this SQL Query transfers the concatenated string to a table that my Label Software queries for data to create the label with.

INSERT INTO AccessMotorLabelData ( PalletNumber, [Count], PartNumber, PalletLabel )
SELECT DISTINCT tempMotors_to_Warehouse.PalletNumber, tempMotors_to_Warehouse.[Count], tempMotors_to_Warehouse.PartNumber, [tempMotorPalletLabel].PalletLabel
FROM tempMotors_to_Warehouse INNER JOIN tempMotorPalletLabel ON tempMotors_to_Warehouse.PalletLabel=[tempMotorPalletLabel].PalletLabel;

View 14 Replies View Related

Queries :: Filtering Query Based On Form

Jan 16, 2014

I have a form named form1. In the form I have two unbound text boxes formated as general date; startdate and enddate are the text box names. In my query criteria for the ContactDateTime field I put the following code

Code:
[Forms]![Form1]![StartDate] And [Forms]![Form1]![EndDate]

When I run it I don't get any results. So it runs but no records come up. I have about five queries that run when I click a button and I want to be able to just select start and end dates once on the form and have all the quieries run.

View 3 Replies View Related

Queries :: Variable In A Select Query?

Jul 10, 2013

Im trying to pass a list box variable in a select query. I understand you cannot pass a variable directly but have to pass it through a function. I may be wrong in this, but whatever I do I cannot get it to work. Here's my code:-

Public Sub GetEquipment()
List387.RowSourceType = "Table/Query"
List387.RowSource = "SELECT findequipstr() FROM Equipment"
End Sub

Public Function findequipstr() As String
If IsNull(List371.Value) Then GoTo function_end
findequipstr = List371.Value
function_end:
End Function

If I MsgBox(findequipstr()) within my Getequipment function, the variable is messaged,

View 3 Replies View Related

Queries :: Put A Value From Total Query Into Variable

Nov 21, 2014

I have a query like this

SELECT qryBONUS_pre.PACIENT_ID, Sum(qryBONUS_pred.TOTAL) AS SumOfTOTAL
FROM qryBONUS_pre.TOTAL
GROUP BY qryBONUS_pre.PACIENT_ID;

I like SumOfTOTAL to put into a variable

How to do it

View 2 Replies View Related

Queries :: Query With Advanced Variable?

May 10, 2013

I wan't to create special query who show only special package. It must work that.

1. Client logg in. System rember his chose. varPrawa="Client" and varIDLogin=5

2. Client click at button "Show Your Package". At that moment query haven't got any criteria so it show every package but it must show only package with IDClient=varIDLogin so only package with IDClient=5 it is easy to create. I tell more it is still easy to join other person but only with varPrawa="Client" i want to create one query who must select by.

WHEN varPrawa="Client" then show only package with IDClient=varIDLogin

WHEN varPrawa="Kurier" then show only package with IDKurier=varIDLogin

WHEN varPrawa="Spedytor" then show only package with IDSpedytor=varIDLogin

WHEN varPrawa="Administrator" then show all package without varIDLogin criteria.

I create subraport who use chosen package in my list and display all special data using varaible but my problem is how to create query whose can select and display only package of that Client or Kurier or Spedytor.

At the end

When Client is online he can see only his packages special IDClient (any IDKurier, IDSpedytor)
When Kurier is online he can see only his packages special IDKurier (any IDClient, IDSpedytor)
When Spedytor is online he can see only his packages special IDSpedytor (any IDClient, IDKurier)
When Administrator is on line he can see all packages (any IDClient, IDKurier, IDSpedytor)

How i can create this query?

View 5 Replies View Related

Queries :: Filtering Query With Text Box And Combo Boxes

Jul 23, 2015

I am creating a query that should filter records of events based on multiple fields. The filters should work with any combination of field criteria, but only two of the four field are working properly, as follows:

1. a text box for searching with event name (free text) - this is working;
2. a combo box to filter events by country name - this is working;
3. a combo box to filter events by event's keyword (category) - this is NOT working;
4. a combo box to filter events by year - this is NOT working

View 2 Replies View Related

Queries :: Name A Field In A Query Or A Table With A Variable Name?

Jul 19, 2014

is it possible to name a field in a query or a table with a variable name?

For example:

I want to choose in listbox "fieldname" the name of the field.

And the query field name looks like:

Code:
forms![testform]![fieldname]: FieldOfTheTable

Unfortunately it doesn't work.

Also if I save the choosen fieldname in a vba function.

Code:
fieldNameFunction(): FieldOfTheTable

This doesn't work, too.

View 14 Replies View Related

Queries :: Get Output Of Query In A Parameter (VBA Variable)

Jul 1, 2015

How could i get output of a Query in a VBA variable ?? I'm trying as below butIi'm getting error:

Dim output As Integer
vari = DoCmd.OpenQuery("qryCompare", acViewNormal, acReadOnly)

Output of a query is a single MAX value.

View 4 Replies View Related

Queries :: Form Filtering And Creating Query - Move Top X To New Table

Jan 24, 2015

Tried to find things but being a mix of a couple of different actions havn't been able to actually find it

So basically I found a awesome form somewhere that builds the SQL query based on all the users selections.

When you hit the create button it will save the query and update the sub data sheet below with your query results.

From here the part I'm lost on is getting the TOP x number of records and moving them to a new table, I wanted it to work on the 2 drop down boxes that are on the form. select your values and hit the button.

I'd imagine it would be a sub query that I'd use for the top x like I have in the past but I just can't seem to get it to work

Quick steps

1. create your query
2. check your data in the sub datasheet
3. decide the number of records to move to the new table
4. select the name
5. hit the button

This would copy the ban, xcv & dfs fields from the importeddata table to the moverecordshere table & also update persname in the moverecordshere table with the name selected in the form.

Sample db attached ....

View 1 Replies View Related

Queries :: MS Access Cross Tab Query - Date Range Filtering

Aug 14, 2013

I just wanted to know how can i set a parameter on the following cross tab query to filter dates. Date field is [pdate By Day].

TRANSFORM Sum([PettyMaster Query2].Amount) AS SumOfAmount
SELECT [PettyMaster Query2].[Petty Cat].Field2, [PettyMaster Query2].[pdate By Day], [PettyMaster Query2].ProjLoc, [PettyMaster Query2].descriptionofpay, [PettyMaster Query2].projno
FROM PettyMaster, [PettyMaster Query2]
GROUP BY [PettyMaster Query2].[Petty Cat].Field2, [PettyMaster Query2].[pdate By Day], [PettyMaster Query2].ProjLoc, [PettyMaster Query2].descriptionofpay, [PettyMaster Query2].projno
PIVOT [PettyMaster Query2].PettyCOA.Field2;

View 11 Replies View Related

Queries :: Copy Query Parameter That Is Entered To A Variable

Feb 12, 2014

I am trying to copy the parameter value that is entered to a variable so that it can be used to run other queries without typing it in over and over. Once my form is finished it will run 4 queries, and the current setup is that I would have to retype the parameter each time.

View 9 Replies View Related

Queries :: Drop Down - Query Not Combining And Filtering Values Based On A Form

Jul 22, 2014

I have a form (DropDown form) that has 3 drop down fields, you select your values from the drop downs and you would push a command button that runs an event procedure which runs a query (DropDown qry test). The user should have the option of picking any combination of fields to filter by. Or no combination, which would return all values in all fields. So I am basically using the form as parameter's for the query.

The problem I'm having is that my query is returning values for one field AND values for another field. Even if the other values selected are not in the same record. It's not combining the fields together to filter. For example: you pick a Project name and Supplier name, the query will return records that have the project name you selected but it will also return records with the supplier name you selected that have a different project name.

I've attached screen shots of the form and the design view of the query (the screen shot cut off the last column name. It is meant to say "Expr3: [Forms]![DropDown form]![Combo7]").

Using Windows 7,
Access 2010

Is there a way to select multiple values from the drop downs?

View 14 Replies View Related

Extremely Slow Queries

Feb 12, 2007

Im doing this program for a post office and stuff, their DB is Oracle and they want to front end it in Access coz its free or bundled w/ office.

Im using the almost fossilized Access 2000, the laptop Im working on is a2.6 ghz Centrino w/ 1024 MB DDR RAM abd 250 GB HD.

Now, since that I am sure that the machine's specs has nothing to do with it, I want to ask why are my queries so slow?

I have 15 tables each w/ almot 20K records.

So when I query something like this.
SELECT KYOKUSYOCD AS 局所コード, BUNSITUCD AS 分室コード, REREKINO AS 履歴番号, TOKUISAKICD AS 得意先コード, TRIKAMCD AS 取扱科目コード, '得意先局所対応マスタTTOKUKMD01 の局所コード = ' & KYOKUSYOCD & ' と分室コード = ' & BUNSITUCD & ' のペアが、局所マスタTKYOKUMD01 の局所コードと分室コードとして存在していません。' AS エラー内容 FROM TTOKUKMD01 WHERE KYOKUSYOCD & BUNSITUCD NOT IN (SELECT KYOKUSYOCD & BUNSITUCD FROM TKYOKUMD01)

UNION ALL

SELECT KYOKUSYOCD, BUNSITUCD, REREKINO, TOKUISAKICD, TRIKAMCD,'得意先局所対応マスタTTOKUKMD01 の得意先コード = ' & TOKUISAKICD &' が、得意先マスタTTOKUIMD01 の得意先コードとして存在していません。' AS WHATERROR FROM TTOKUKMD01 WHERE TOKUISAKICD NOT IN (SELECT TOKUISAKICD FROM TTOKUIMD01)

UNION ALL

SELECT KYOKUSYOCD, BUNSITUCD, REREKINO, TOKUISAKICD, TRIKAMCD, '得意先局所対応マスタTTOKUKMD01 の得意先コード = ' & TOKUISAKICD & ' が、得意先マスタTTOKUIMD01 の得意先コードとして存在していません。' AS WHATERROR FROM TTOKUKMD01 WHERE TOKUISAKICD NOT IN (SELECT TOKUISITENCD FROM TTORIKMD01)

UNION ALL SELECT KYOKUSYOCD, BUNSITUCD, REREKINO, TOKUISAKICD, TRIKAMCD, '得意先局所対応マスタTTOKUKMD01 の取扱科目コード= ' & TRIKAMCD & ' が、取扱科目マスタTTORIKMD01 の取扱科目コードとして存在していません。' AS WHATERROR FROM TTOKUKMD01 WHERE TRIKAMCD NOT IN (SELECT TRIKAMCD FROM TTORIKMD01);


Its soooooo slow, as in 6 minutes loading slow, windows xp running on pentium 2 slow, very very... ok you guys get it already.

Please help me coz Im losing my mind already. I did one version in SQL Server and it worked just fine. Sad thing is, they lvoe their VBA apps coz it can be like engraved in Excel or something. Anyway please help

View 1 Replies View Related

Access Slow To Load [really Really Slow!]

Dec 14, 2007

Hi All,

I'm having trouble with access. Basically it has been very slow to load
(over 30 seconds when not opening a database) and when opening a database it just crashes.

Has anyone any idea what could cause this as it worked fine before ?

also would a reinstall help ??

-Elfman

View 3 Replies View Related

General :: Slow Queries On Objects - Possibly Old Object Refs In MSysObjects?

Oct 10, 2013

I have a db that is having some strange speed issues on some very basic queries. Objects that have a rowsource/recordsource with a SQL statment in particular are really slow to populate. Likewise on deactivate/activate the report query seems to reload. I've put breakpoints in every object event with no stops out of the ordinary, and nothing seems unusual.

While I know MSysObjects is a user read-only table, I came across some records that reference objects that no longer exist in the front-end. Is this table cumulative? Is there any way to purge the deprecated records? I tried to turn on then turn off autocorrect features hoping that would trigger it to repopulate, but no luck.

I'm thinking this may be the source of the issue. Perhaps if it is looking for an object that it can not find (especially the ~sq_ unsaved queries) then it's looking to the wrong place on a lostfocus/activate/deactivate or similar event.

Some history on this file, it has been through many versions of Access starting with 2003, which I think is part of the issue as well. Shy of looping every object and replicating the read-write properties, I'm not sure where else to go with this.

View 2 Replies View Related

Queries :: Using Variable In A List Field Query - Getting Complete List On Initial View

Mar 28, 2014

In my access form I provide the user a list of locations from various countries in a listbox . But the list is too long so I provide him a combobox for selecting a country. Selecting the country should update the listbox showing only the locations in that specific country.

So my SELECT from the listbox must cover the unselected state and show all entries and when a country is selected it must narrow the selection.

I tried to get this happen with the following SELECT statement containing a variable. Choosing a country in the Combobox results in a change of the variable and in a requery. This works after the first country is selected and for each country change, but the initial list is empty.

VBA in the loadform
'Application.TempVars.Add "varcountryselect", "*"
SELECT in the listbox "lstlocationsperproject"
SELECT tbllocations.locationID, tbllocations.country, tbllocations.localstreet, tbllocations.localcity FROM tbllocations WHERE ((tbllocations.country) Like [TempVar]![varcountryselect]);

VBA in the combobox
Application.TempVars("varcountryselect") = [Form]![kombcountryselect].Column(0)
Me.lstlocationsperproject.Requery

The values in [kombcountryselect].Column(0) are texts like "SPAIN", "MEXICO", etc.

Any hints, how I have to use the * for getting the complete list on the initial view ?

View 5 Replies View Related

Union Query Very Slow

Sep 27, 2005

Hi,
In my database im using several union queries as they turn out to be very useful.
However, whenever I have a calculation that involves one of the union queries, things happen at a very slow pace. Is there a way to speed it up a bit?
Thank you
Stacey

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved