Query Doubling Results
Nov 27, 2007
In My Db I have TblDatabase (contains company details) and TblContacts (contact details relating to the company joined on a one-many relationship.
I also have Tbl calls which records contact history with each company.
I made a query to output a report based on the source of the Company. What i am finding is that companies which have more than one contact, the contact history repeats itself by the number of contacts in the company, can anybody point me in the right direction. Here is my query:
SELECT DISTINCT TblDatabase.CompanyName, TblDatabase.RegisteredDate, TblDatabase.City, TblDatabase.WebSiteAddress, TblDatabase.BusinessDescription, TblCalls.[Call Note], TblDatabaseContacts.[First Name], TblDatabaseContacts.[Email Address], TblCalls.Result
FROM (TblDatabase INNER JOIN TblCalls ON TblDatabase.CompanyCode = TblCalls.CompanyCode) INNER JOIN TblDatabaseContacts ON TblDatabase.CompanyCode = TblDatabaseContacts.CompanyCode
WHERE (((TblDatabase.Source)=[forms].[FrmSourceReport].[ComboSource]));
View Replies
ADVERTISEMENT
Mar 14, 2006
Have a crosstab query for a running 12 months that is used for a report and I noticed today that each month is correct except that it is also picking up Feb of last year as well as this year. All other months are good. No other pre-queries have any date ranges in them. Anyone know what I have to do to prevent this problem? Below is my SQL.:confused:
TRANSFORM Sum([92660ScorecardUnionName].Hrs) AS SumOfHrs
SELECT [92660ScorecardUnionName].EMPID, [92660ScorecardUnionName].Category, [92660ScorecardUnionName].OPID, [92660ScorecardUnionName].NAME, [92660ScorecardUnionName].Description, Avg([92660ScorecardUnionName].Hrs) AS [Avg Of Hrs]
FROM 92660ScorecardUnionName
GROUP BY [92660ScorecardUnionName].EMPID, [92660ScorecardUnionName].Category, [92660ScorecardUnionName].OPID, [92660ScorecardUnionName].NAME, [92660ScorecardUnionName].Description
PIVOT Format([Date],"mmm") In ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug',' Sep','Oct','Nov','Dec');
View 2 Replies
View Related
Apr 1, 2008
I used to queries ,1 to get items that are taken ( its all about sign in sign out for equipment) and other query is list of all items.
How can i make 3rd query which will give me all but taken items from query1?
(of course items from query 1 are in query2)
thx in advance
View 7 Replies
View Related
Mar 24, 2013
I am trying to do the good 'ol sales report (query) to include customers with no sales.
I have a customers table, account number table, sales table & sales (line) detail table. (all linked in that order)
If I run a query to show customers (in the customer table) with account numbers, that works
An unmatched query to show customer without an account number works (but of course the unmatched account number field isn't shown).
How can I get the two two be shown together with the "unmatched" having a null or 0 for their account number?
I am guessing in principle, the resulting solution can be modified to show customers without sales alongside those with sales?
View 3 Replies
View Related
Apr 2, 2013
I run a physical therapy office and patients come in for treatment either 3, 4 or 5 times per week. My database is used to track these frequencies (among other things).
I have 3 queries which count how many patients come in 5, 4 and 3 times/week.
In my main table I have fields called "how many 5's", "how many 4's" and "how many 3's".
I have tried to design an update query which will update those fileds in my main table to reflect the counts in the 3 queries mentioned above.
(I'm not using SQL view, I'm using the query design view)
In the "update to:" row, I use the Build function and locate the count I'm looking for.
Problem: when I run the query I get the error: Operation must use an updateable query.
View 3 Replies
View Related
Jan 3, 2008
Here's my problem. I need to generate a report that says how much of each individual product was produced and as well as the total produced for a specified category in a time period. Something like the following:
05 Catagory A: 02 Product AA, 01 Product AB, 02 Product AC
10 Category B: 07 Product BA, 03 Product BB
04 Category C: 01 Product CA, 01 Product CB, 01 Product CC, 01 Product CD
etc...
I currently have a query that queries a database and pulls out all products that were produced in a specified period and the categories they belong to and dump them into a local access table. Now what I need to do is search through the query results and count up how many of each product were produced (02 AA, 01 AB, etc...) and the totals for each category. The number of categories is pretty limited (6), but there are hundreds of product codes, so I need a way to do this without having to type in each induvidual product code as the requirement by which the query searches. Also, the product codes that get returned are different every day.
I was thinking something along the lines of take the product code of the first row and check for any others in the results that match and write that into another table. Then move onto row 2 and use its product code as a search parameter and search through the query results for any matches. Then continue that until the end of the query results. Can I do that? Is there a better way to achieve what I need?
View 7 Replies
View Related
Nov 14, 2007
I am trying to filter a form to show the entire weekend's activity on Monday but only yesterday's activity Tuesday through Friday. Using this code I can return Friday's results on Monday and yesterday's for the rest. How do I get the range Friday to Sunday?
IIf(DatePart("w",Now())=2,Date()-3,Date()-1)
Using >Date()-3 doesn't work.
Thanks
Bruce
View 5 Replies
View Related
Aug 30, 2005
I have a query that displays results in a form, but if the query is null, I want to display a different form, or just an error message that says something like "your query returned no results" (right now it will display the form with no fields)
I am a beginning Access/VBA user and have searched and browsed the forum for combinations of null/query/form, but haven't found what I need. Can anyone point me in the right direction?
Thanks for any help.
View 5 Replies
View Related
Nov 30, 2005
I am wanting my query results to appear in my main form so that i can edit them, rather than a table the query is just a look up of my form that stores about 500 records and stores all the same fields
any help would be appreciated
thanks
View 1 Replies
View Related
May 21, 2007
Is there a way to write one query that will work for different criteria and is run by different buttons to produce bar graphs or a basic report depending on the button the user clicks??
View 5 Replies
View Related
Jul 22, 2007
Hi all :o
I am working on a query but can manage to get it to do what I want.
I have a main table with a job_ID and a faults table which documents faults that occur related to that Job_ID the tables are related with a one to many relationship. I want the query to bring up all the jobs even those with no faults, at present it is only bring up those jobs that have faults, how do I include details of all the jobs and if there are no faults then that field is left blank, probably very simple to do but after working on this db for hours my brain is no longer functioning!! :eek:
Thanks
Jackie
View 2 Replies
View Related
Jan 4, 2008
Hello all,
I have a table called tblODF and within that table, I have these fields:
- ODFNumber
- ODFScanDate
- Status (Combo box: Pending, Complete, Licensing)
- LastFollowup
In my query, I have the same fields, except I added a calculated field.
I added DayCount to
Codecalculate:(Date()-[ODFScanDate]
This should calculate the number we've had the ODF.
What I want to happen is, let's say the status is Maturity, I want the DayCount to say 0. If it's pending, I want it to calculate the actual days.
Is this possible?
Thanks
View 5 Replies
View Related
Nov 19, 2007
I've just started using Access 2007, but I've been an Access 2003 user for some years and have a couple of databases, both of which I've now brought over to 2007.
Something I've noticed and is probably very simple. In 2007, after I entered information in a table via one of my forms, I queried on that information but it wasn't included in the results. But everything else - from 2003 - was. I then went thru each field in the underlying table to "match" fields there were filled in for a 2003 record and now the new entry does appear in the query results.
This hadn't happened before in 2003 - it didn't matter if all or even particular fields were filled in. But now it needs for at least some particular fields to be filled in. Don't know if it's something different in 2007, or probably coincidental. I haven't changed anything in the table, query or entry form.
It's not a crisis (now that I see my results), but I'm wondering what is going on - now, that apparently wasn't occurring before?
Thanks!
View 1 Replies
View Related
Dec 6, 2005
I hope I can explain this clearly. I'd be really grateful if anyone could help.
I need to set up some sort of contacts database at work.
I need (I think, after having a little think about it) one table, filled with people, (their names, contact details ect) and basically various queries to pull up people in certain groups. Say for instance, people who attend meeting a, b, c, (in a simplised, condensed version of the truth)
I did think about doing this with various tables actually. A contacts table, a meetings table, blah blah, but anyway. (Any advice on this incidentally would be great).
My main problem though. We often have to email all the people who attend say meeting a. We have contacts on our email systems, but they're different from person to person, and as the company is updating email systems, we can't even send contacts lists to everyone, as they're not compatible.
What I'd love is to be able to call up a list of people attending meeting a from my database and email each of those people (their contact details would include email address of course)
Does that make sense?
Is there any way of doing this?
I'd be really happy if anyone knew...
View 9 Replies
View Related
Aug 30, 2005
This is a rael daft question, but how do I get the results of a query into a table?
View 5 Replies
View Related
Jun 6, 2005
:( I have such problem : my query works right, but in ComboBox I got results with wrong sort.
Query results is:
Street 8
Street 8a
Street 10
Street 10/12
But in ComboBox data views such:
Street 10/12
Street 10
Street 8a
Street 8
Please help me!
View 2 Replies
View Related
Jun 23, 2005
Hi,
I have a query with two table's in them. One is filled, the other is still empty.
Both table's are related to each other with the field "document number".
This was working fine in access 2000, now in 2003 it returns zero results.
I am starting to think it is because one table is empty it returns nothing.
How can i adapt the query criteria or something else that it shows the results from table one, while table two can still be empty.
One table holds the documents and all information about it, the other holds the information wich document is referenced on wich document. Now since i can have documens which don't reference to a document, i still want those in the list.
Anybody any idea?
Thanks
View 1 Replies
View Related
Jul 19, 2005
I know SQL, and I know databases, but this has me confrused.
I describe it in terms of macros, but I get the same results if I manually execute the queries.
A client has an Access DB that is used by the 5 employees in the office. He has a macro that creates an interim user list, then compares it the the user list from the start of the month.
If he runs the macro to create the interim user list from his computer (computer 1) then any computer can run the other macro and get the differences (about 200 rows).
If any other computer creates the interim user list, then any computer that runs the macro to calculate differences gets invalid results (>3000 rows).
A union of the 'good' interim user list and 'bad' interim user list shows about 3000 rows (out of 4345 rows in each original table), so the macro produces 1345 differenct rows, depending which computer it is on.
I verified that each computer is opening the correct database, and the query is a moderately simple INSERT INTO ... SELECT FROM query.
Does anyone know why this might happen, and/or an easy way to determine which rows are different, and why? It is Access 2003 with SP1, everyone has the same version.
View 1 Replies
View Related
Aug 2, 2005
Does anyone know how to do a query so that the user can find all the things that will expiry at the end of the current month?
The user will click on a command button and it will show the results of a product that will expiry at the end of a current month.
Have tried with parameters to which the user manually types the end date in and then it will show the results but having problems.
Cheers
View 4 Replies
View Related
Aug 4, 2005
hi,
I've got a problem with multiple rows that I want flattened into one row.
In the attached database, I've created a simplified version of my problem.
The database has two tables, TestItems and Results. In Results, there are four Result columns, representing results of different types of tests.
The two tables are linked on ItemID.
For each record in Results, only one result column will have a value, the others will be NULL. And there is only one result of each type for each test item ID.
The "Test Results" query returns all results, with a separate row for each Result record. For example:
ItemID ItemNameResultType1ResultType2ResultType3ResultType4
1 antelope1
1 antelope3
1 antelope3
1 antelopeyes
All well and good. BUT, I need the results collapsed into one row so that I get all results for each test item on a single row:
ItemID ItemNameResultType1ResultType2ResultType3ResultType4
1 antelope133yes
Does anyone have any idea how I can do this?
Many thanks
Andy
View 1 Replies
View Related
Oct 13, 2005
Hi!
I have query with one column results
How to put automatically results of this query into one column table
Thank's a lot
View 1 Replies
View Related
Dec 16, 2005
SELECT idAuswertung, fiPrüffeld, fiAuswertungMaster, fiAuswertungTyp, AuswertungName, AuswertungSort, AuswertungActive, (SELECT COUNT ([idDiagramm]) FROM tkey_Diagramm WHERE fiAuswertung = [idAuswertung] ) AS AnzDiagramm
FROM tkey_Auswertung;
Why can I not edit the results when I use the Subquery above?
Without the Subquery all works fine.
Christoph
View 1 Replies
View Related
Dec 16, 2005
Hello,
my problem is, I have a form with a sub-form that displays results of a certain query. Now, on the main form I have buttons that manipulate this query.
What I want is, after the SQL of this query has been changed, the sub-form to show updated query results based on the changed SQL. When I close and re-open the form, the sub-form shows the most recent query results, but I want this without having to close and re-open the form, how?
In the VBA code, I already the "Requery" method of the sub-form but I guess I need to do something with the querydef object, too....
Thanks in advance!
Victor
View 2 Replies
View Related
Apr 10, 2006
I understand that trying to edit a query from multiple tables will not work as the link to the record is "broken". However, is there a way to filter a table and edit the results in a form view. In other words my table holds data for 42 supervisors. I would like to get a form view of the particular sup that is signed in. I can get the results into a form but the records appear to be locked. The Record lock feature to the form is set to "No Locks".
any ideas would be greatly appreciated
Ricky
View 1 Replies
View Related
Apr 27, 2006
hello. i have a database form which, through combo boxes, allows a user to enter variables and print their desired data in table form. the database searches a table that contains a lot of data. for example, you can find the number of people that speak specific languages in a certain country.
anyway, there are a lot of languages in my table and i do not have data for each specific language. what i want is the query to print only those columns from the table (that relate to the specific chosen country) containing data. if i use the IS NOT NULL command, every time a row does not contain a value, that entire entry is not printed.
anyone have any ideas? is what i want to do even possible in access? any help is much appreciated.
View 3 Replies
View Related
Apr 28, 2006
Hi
I have a problem sorting some query data and I wonder if someone could help point me in the right direction.
I have a query with two columns, in the first column is a number (either 6 or 7) and the second is the name of a business. Eg
Column 1 Column 2
6 Pizzas & Co
6 Pizzas & Co
7 Pizzas & Co
6 IPM Ltd
7 IPM Ltd
6 Computer Sales Ltd
6 Computer Sales Ltd
6 Computer Sales Ltd
7 Computer Sales Ltd
7 Computer Sales Ltd
7 Computer Sales Ltd
7 Computer Sales Ltd
7 Computer Sales Ltd
And I want to produce some another query so that the output which looks like:
Column 1 Column 2 (6's) Column 3 (7's)
Pizzas & Co 2 1
IPM Ltd 1 1
Computer Sales Ltd 3 5
So for each company name, I am essentially doing a frequency count for all the 6's and 7's.
I think this must be relatively easy to do, but I am getting it wrapped around my head!
Many Thanks,
Lee
View 2 Replies
View Related