Queries :: Creating A List Based On Multiple Queries
Jun 23, 2015
I have 3 select queries which Im trying to output to a combo - Ive tried a UNION query but I get an error
ODBC-- call failed ODBC Driver SQLBase.....
Firstly is do the results need to match within a union query? I mean they have no relationship what so ever Im just trying to populate this combo with the same results.
Secondly is there a better way to do it? 2 of the select queries query a linked SQL table and the third is a local table. All of the select queries work on their own.
I have a DB where you there's 5 tables all linked together by one project ID
tables below
Project , Staff, Asset, allowances, travel, mark up
What I can do is create a new project, then add records to each of the other tables on what different items I require,
i.e. I create a new project - called project one, in the project table I create a record stating, name, time scale, client and location, then I add different records to each of the other tables on what I require all linked to the same project ID. (probably not explained that too well)
Now I want to create a query that lists all the requirements one after the other this will make it easier to create reports and to calculate costing's.
At the moment I have made 5 different queries listing all the data, then have one report containing 5 sub reports to display the data, no this does work.
I would like a query which would look at the difference between TBL_Sales and TBL_Finance and will then add rows to TBL_Sales to make them balance. In the example above I would want it to add the following (I've used C as a Product_Type to show that it's a manually entered value) -
I have some code that creates queries based on a value in a checkbox.
So, depending on that value, the queries may or may not exist.
I need to take those queries (if the exist) and create one union query.
This code creates the first query beautifully, but it won't union the second query.
Code: Private Sub cmdSubmit_Click() Dim blnQueryExists As Boolean Dim cat As New ADOX.Catalog Dim cmd As New ADODB.Command Dim qry As ADOX.View blnQueryExists = False
I have a table (let's call it "tableA) with about 7 fields. One of the fields contains information that I need to do a query on so that I may find specific payees, for example:
The field is called "Payee" and in that field for each record, the information could be "At&T", "A T and T" or "Abercrombie & Fi", but there is also other information in that field along with At&T, etc., so the field for a record may look like this: A T AND T MOBILI A T AND T MOBILI 10 90034 Bill Pay or ABERCROMBIE & FI 3042 PP 10 9111 DIRECT
Is there a way to set up another table (let's call it tableB) to have all the Payees names (such as AT&T or whatever) in it and by the push of a button (maybe macro), have a query go out and find all matches from tableB in tablea?
So, basically have the query look in tableA and find all the matches from TableB. Please understand that tableA could have records that contain the same name, but spelled a number of different ways, for example, AT&T or A T and T or ATandT or ATT. Again these names may or may not be embedded in with other information in a field.
Or is there a way that an Access query can look into an external list and find the records, example:
Have a text (file) list with all the names (separated by a comma or space - AT&T, AT & T, Amercrombie and FI, Abercom&Fitch, etc. Now have a query go to that list and find all records that match in my tableA?
I have a scheduling database that I am only using one table "DateLog"
It contains these fields: JobIDInt-PK LotIDTxt-PK TaskIDInt-PK - List from TaskList Table TripIDInt-PK TaskDateDate ForemanIDInt - List from Foreman Table TaskQtyInt TaskMisc1Txt TaskMisc2Txt NotesMemo
Every time a trip is taken to a job site, a record is created. I would like to have a datasheet view of this table that will join all of the tasks for a particular JobID and LotID together on the same record for easy viewing. The list of tasks are static and will not change from job to job. The only fields that needs to be seen are the JobID and LotID at the row header. The rest of the data is the TaskDate for each task.
What I have attempted so far is to create a separate query for each TaskID and then to join them by the JobID and LotID. I have gotten to the point that I can put values into the datasheet, but I get an error that the primary key cannot be null.
Am I approaching this the correct way? Is there a way I can point the hidden key fields to the fields they are joined to? Access does not seem to be smart enough to figure this out itsself and I am not sure how to tell it to create the new record using the fields that it is related to.
This is very difficult to explain, any help would be greatly appreciated. I will be glad to post further clarification if I did a bad job explaining what I am trying to do.
I have a query which is used to pull data from 2 tables.
1. Only show the records that have 2 or more same Pat#, FName and LName. If it is a single record I would like to hide it.
2. Need to see the different dates amd know the difference.
Currently Query Looks like this.
Pat# FName LName Reason Status Date 00001 John Doe 1 1 11/13/2014 00002 Sally Doe 2 1 11/25/2014 00003 Bill Bates 1 1 11/04/2014 00003 Bill Bates 2 1 11/07/2014 00004 Jenny West 1 1 04/03/2014 00004 Jenny West 2 1 04/10/2014
The Signup reason number 1 represents the signup date and number 2 represents the time they left. SignupStatus number 1 represents a group.
So I am hoping my end goal it would look something like this.
Pat# FName LName Date 1 Date 2 Difference 00003 Bill Bates 11/04/2014 11/07/2014 3 Days 00004 Jenny West 04/03/2014 04/10/2014 7 days
I am trying to avoid using VBA or SQL. I do not know where to input it.
I tried to use the “Find Duplicates” query wizard but this did not work because it finds duplicates like last name first name, but it does not separate the dates.
I'm working on a contact database for my company's sales efforts. It tracks interactions with prospective customers and assigns them to employees here. My question is this: For mass contact efforts (such as mailings), is there a way to create mass entries to my "Interactions" table so that no one has to enter a mailout interaction 1000+ times?
Structure of the relevant bits of the database is as follows:
Contacts Table Interaction Table
Contacts Table is linked with Interaction table via ContactID
Queries are run to narrow Contacts by various criteria (ex.: by the employee they're assigned to).
So if I run a query to get all the contacts assigned to me, and there are 450 of them, and I send a mailout to all of them, and I want to add an interaction to those 450 people, is there an automated way to do this?
I need to count records based on multiple criteria from two different tables. I have two tables (i.e. "tblTasks" and "tblTaskHistory"). The tables have a one-to-many relationship based on the "TaskID" field. "tblTasks" has a field called "AssignedTo" and "tblTaskHistory" has a field called "TaskStatus". I need to know how many tasks have been "reopened", the "reopened" status is located in the "TaskStatus" field in "tblTaskHistory". I need this count against a unique listing of employees which can be found in the "AssignedTo" field in "tblTasks".
I have been running 5 reports to gather company information. I then take the data from these 5 reports and manually load them into an Excel spreadsheet to calculate a grand total. I would like to be able to run a query or report within my database to get the same information. I have attached a copy of my spreadsheet for review.
Could someone please review this spreadsheet and help me design an easier method of calculating a grand total.
I have a list box (List25) that is generated from a query (qryThisBox). One of the fields in that query uses the criteria [Forms]![MyForm]![SelectedField] to filter.I also have combo boxes in the form that List25 displays in. Unfortunately, I want to requery the list box in the form, using a combo box that calls the same underlying table field, SelectedField.
How can I do this? Can I somehow dynamically change the criteria in qryThisBox to change when it gets requeried?How do I stack combo box requeries, eg: Combo Box 1 gets selected - does a requery
and/or
Combo Box 2 gets selected - and filters the results of the requery for Combo Box 1.
I have a query that allows the user to put in a date range - this works.He also wants to limit what he prints.
For example at the moment he gets
OrderA rest of line 1 for orderA OrderA rest of line 2 for orderA OrderA rest of line 3 for orderA OrderB rest of line 1 for orderB OrderC rest of line 1 for orderC OrderC rest of line 2 for orderC OrderD rest of line 1 for orderD . . .OrderZ etc
He only wants to say print lines for OrderA and OrderD. It's he's choice and not based on anything else already in the table.
I see that in the criteria on the design for the query it allows me to bbuild an expression and I can select a list box on the form such as
[Forms]![name of form where list box is]![name of list box].[EXPRESSION VALUES]
I don't know which expression value to choose. I have tried afterupdate and beforeupdate but none of the rest look like they are the ones I should be using.
I have DB used for inventory for many different categories. I have a table and form for the following: Location, Printers, Pc's and many more.
What i am trying to accomplish is to have a advanced search form that will display how many pc's and there makes and model from selecting the location name or Cost center from a combo box.
So an example would be I want to select MPP-WDF from the combo box click a button and it will return the number of PC and there makes of model's and some other information in a list of records.
1 - Maintenance Order 2 - Breakdown Order 3 - Greasing Order
On my form I have two list boxes: An Order Type List box, and an Area Listbox.What query criteria or VBA code would I use so that I could populate a text box with the relevant order number based on the selections of the list boxes. i.e. MaintenanceOrder & Area Z would display MaintenanceOrderNoZ.
I have a form on which I have placed a list box which will return data from a query via cmd button.
Is it possible to use the same listbox to see different queries, using different cmd buttons? I will place multiple button each one of which will run a query that will show its data in the list box.
I have a list box with a row source query as follows...
SELECT qryPendingCompletions2.ID, qryPendingCompletions2.Department, qryPendingCompletions2.[Employee Name], qryPendingCompletions2.CompletionDate AS [Completion Date], qryPendingCompletions2.[Entered By], qryPendingCompletions2.Goal, qryPendingCompletions2.Comments, qryPendingCompletions2.[Verified By] FROM qryPendingCompletions2 WHERE (((qryPendingCompletions2.Department)=[cbocurrentemployee].[column](3)) AND ((qryPendingCompletions2.[Verified By]) Is Null)) ORDER BY qryPendingCompletions2.Department;
I also have a combo box at the top of the form showing what user is logged in where the row source query is the following...
SELECT Employees.UserID, [First Name] & " " & [Last Name] AS EFullname, Employees.AccessLevelID, Employees.Department FROM Employees WHERE (((Employees.AccessLevelID)=1 Or (Employees.AccessLevelID)=2 Or (Employees.AccessLevelID)=3 Or (Employees.AccessLevelID)=4));
How to only list the data in the list box when the department is the same as the logged in user.
So I'd like to add the criteria to the first query something like criteria = [cbocurrentemployee].[column](3) but this doesn't seem to work as criteria in queries.
I have a table where one of the fields is a list box, where it is possible to select more than one option. The options correspond to records in another table. I have a query that includes this list box field. The problem is that if someone has made two selections in the list box, the query creates two records, each featuring just one of selections from the list box. Can I get this query to hold the two selections in one record? This might be especially challenging because the query field is pulling attachments.
Long Version:
I have a table [Master List] (primary key is TagNumber), where one of the fields is a list box, [Standard Methods]. You can select multiple choices in this list box, which corresponds to a table also called [Standard Methods]. In the Standard Methods table, there are two fields for naming the method and attaching the PDF which describes the method.
I have a query called [Get Attachments] that is set to bring in different attachment fields from different tables, including [Standard Methods]. The problem is that the query creates a different record for each selection made in the list box. For instance, if you select two standard methods for a certain tag number in the list box, this query will have two records for that tag number, each with one of the method attachments. Is there a way so that the query just creates one record, with both attachments in that record???
It should also be noted that I am using Outer Joins, so that the query includes TagNumber records from the Master List even if there are no attachments for it.
When creating a query I have set up a parameter query as instructed (in this case searching for a name) but when I run the query it returns the error 'this expression is typed incorrectly etc.'
I have worked out that this must be due to the fact that the names are not typed in by a front-end user but need to be chosen from a dropdown list (which i have stored in a separate table) - So, the query seems to fail based on that.
I'm trying to build a query that uses the information pulled from controls on a form called "CharacterCreation" - 2 of the controls are "Race" and "Class", and the form stores this data in a "Characters" table.The query needs to refer to the Characters table, and another table called "Modifiers".In this second table I have several numerical fields such as hp, str, etc, and I have two other fields called "Type_Modifier" and "Type" Among the Type_Modifiers are Race and Class, where their corresponding "Type" could be for instance Demon and Magician..
So the idea is that when I mark on the form (and thus creating the record in the first table) a Race of "Demon", and a class of "Magician" I want the query to refer to both of these fields, and sum the values in the second table where the "Type" is either "Demon" or "Magician" or whatever I decided to choose. I feel like I should be able to figure this out but I'm having a hard time..Here's an example of the SQL I've tried that shows nothing.
Code: SELECT Characters.Char_Name, Sum(Modifiers.hp) AS SumOfhp FROM Modifiers INNER JOIN Characters ON (Modifiers.Type = Characters.Class) AND (Modifiers.Type = Characters.Color2) AND (Modifiers.Type = Characters.Color1) AND (Modifiers.Type = Characters.Species) AND (Modifiers.Type = Characters.Race) GROUP BY Characters.Char_Name, Modifiers.Type HAVING (((Modifiers.Type)=[Characters].[Race]));
I also tried this, which I thought would work but it displays nothing as well.
Code: SELECT Characters.Char_Name, Sum(Modifiers.hp) AS SumOfhp FROM Modifiers INNER JOIN Characters ON (Modifiers.Type = Characters.Class) AND (Modifiers.Type = Characters.Color2) AND (Modifiers.Type = Characters.Color1) AND (Modifiers.Type = Characters.Species) AND (Modifiers.Type = Characters.Race) GROUP BY Characters.Char_Name, [Type]=[Characters].[Race];
If I want to sum the percentages from April, May and June only if a column is Not Null, how would I do that?
example
Tbl 1 PK, Month Percent
Tbl 2 FK, Month Enrolled Qty of Rx in the 1st month enrolled Qty of Rx in 2nd qtr Base (if Qty of Rx in 2nd Qtr is null then Qty of Rx in 1st month enrolled)
If Qty of Rx in 2nd QTR is NOT NULL then QTY of Rx in 2nd Qtr * Sum of April Percent+May Percent+June Percent, otherwise Qty of Rx in 1st month enrolled * Month Percent
Im getting stuck on how to sum the percents of April, May and June and then multiplying the result times the Qty ONLY IF the field is not null.
I only know how to create Query's using the design mode. I dont know how to write SQL statements.
I currently have a form to manage inventory. On the left side of the form, I have a list box that shows all of the items in the database and finds the record on the form based on the selection.
I would like to have toggle boxes or something underneath the list box that when clicked will sort the box by vendor and item and another that when clicked will sort the list by part number and then select the record on the form based on the selection at that time.
I have no idea how to accomplish this...can anyone help?
For my study on academic research I need to match patents that refer to academic research as prior work with the actual prior work.
I have two tables (see attached images below).
One regarding AcademicPublications (AP), which is neatly organized with title, year, journal, volume, pages, first author, etc... 480,000 rows
One regarding Patentswhere all this information is hidden within one field, in the most messy way possible... for instance, a field could have:
Quote:
Sugita et al, "Nonsurgical Implantation of a Vascular Ring Prosthesis Using Thermal Shape Memory Ti/Ni Alloy (Nitionl Wire)," Trans. Amer. Soc. Artif. Intern. Organs, vol. 23, pp. 30-34.
or
Quote:
Willingham et al., Cell 13, 501-507 (1978).
Or many other ways.
I want to create a new table that is set up like this:
The question is: How do I match different fields from one table on one field of another and make it return another field (the ID)? Some references are too horrible to match, but I need as many as I can get.
I can imagine two queries would give me the bulk:
A match in [Title] AND [Year]
A match on ([SourceTitle] OR [AbbreviatedSourceTitle] ) AND [Volume] AND [Year] AND [PageStart]
I understand that I have to make use of the Like "*"&[value]&"*", but how do I make it return the matching ID?
I have a production database in which orders are checked for shortages at different levels of production in which :
1 raw product can be fetched in 2 or more final products, Shortages are checked as per priority.
In this database i have tables named "finalproductlist" and "rawproductslist" in which products are connected in one to many (see table "productmapping"). For E.g. 1 product in raw table can be fetched into 2 or more final products.
I have stocks query on both levels with which shortage is checked.
I want to create the order shortage query which gives the shortage at both levels prioritywise.
What I am trying to do is fairly simple i just dont have the ability to correctly code what i want to do.
I want to filter my query based on some criteria in multiple columns. But i only want the query to filter based on the specific criteria if a checkbox has been selected.
Basically i want the criteria for one of the columns criteria to read
IF a check box "Check0" is selected THEN filter the column to only records that = 1 and if "Check2" then filter all records that = 2