SELECT Certain Rows Based On Criteria

May 8, 2007

Hi all,

Very very new to Access, moved department a week ago and inherited a couple of databases that need tweaking. Although I'm learning I am stuck by something very simple and can't find it by searching this forum or Google :)

I have a query that originates from 2 tables, there is one custom record made from 2 of the fields -

Free Stock: [stk_stkqty]-[stk_allstk]

Now I want a record that shows -

Product where the free stock = backorder stock

so theroetically my guess as a beginner is -

SELECT * FROM [Product] WHERE [Free Stock] <> [Back Order]

But it fails miserably on syntax. Can someone point me in the right direction, and I apologise for my lack of understanding in advance.

Boofuls :)

View Replies


ADVERTISEMENT

Query For Populating A Form Based On Different Select Criteria

Feb 20, 2006

Hi all,
I have a query which populates a form called EditPatientFrm, which asks the user to enter the patient UniqueID in order to pull up the record they want to edit from the TblPatient. However, I want the user to now be able to input just one of three criteria in order to pull up the record to be edited:

UniqueID
ChartNumber
PatientLastName and PatientFirstName (two fields)

since they may not have the UniqueID readily available to them.

Can anyone show me how to do this? I have tried to find answer to this one under queries and forms- no avail. Sure it's a simple thing...

thanks!
vrpres

View 1 Replies View Related

Forms :: How To Select A Record Based On Multiple Criteria

May 15, 2013

I have a list of client stored in a table "Clients". I would like a form to present a user with the next client in the list at the click of a button, but there will be some exceptions:

Some clients will be given priority, and should be moved to the top of the list although they may not be the next logical entry in the table. Priority clients are indicated by a field "Priority" with a Yes/No option set before work begins.

Some clients will have requested a call at a certain time of the day - This time will be stored in a field named timeToCall. The next user to click the button after the time has passed should be given that clients details.

When the end of the list is reached any clients who could not be contacted will be tried again. My table currently has a field "Attempts" to track this, but that may not be needed. Clients who have been dealt with will be removed from the "Clients" table to a "Completed" table.

Whichever record is selected will be flagged as being dealt with so that 2 people don't get the same entry. I may add a new field for this, but right now I plan to use the "attempts" field to control this

I am unsure of the best approach to the above, I'm not very well-versed in Access, but if I were doing this in Excel (as originally requested by my boss) I would do it like this:

Use a form where the "Next" button will use VBA code to first check if there are any priority clients, then check if there are any timed client's ready to call and then move to the next entry that has had 0 contact attempts. Whichever record is the next one will be displayed in the form to the user.

View 1 Replies View Related

Insert Records Into Table Based On The Select Criteria From The First Table.

Mar 22, 2005

Hi

I have a small database with 4 tables that I am using for the current problem.
The tables are call, parents, mailman, orders.
Call and parents are related by the call ID (a primary key in the Call table.).
Mailman and orders are related by a Unique Id (a primary key in the mailman table.).

Forms involved are frmmain and frmsub.

Frmmain contains the call table information in the main form and parents information in the subform.

When a user enters a call with call ID and enters the operator name and parents information in the sub form,
When a user clicks the OK button on the main form, necessary changes should take place
if they enter the case type in the sub form part of parent information as ‘missing information’ or ‘missing link’ then the parent information with fields first name, lastname, case type, operator information should be inserted into mailman table in appropriate fields.

Simultaneously a record should be inserted into orders( after the record is first inserted into mailman, since both tables are linked with unique id) with the following information.
Orderid being autonumber.
Uniqueid from the mailman table.
Orderdate system date.
Ordertype should be “Mailman”

View 4 Replies View Related

How Can I Select Only The Rows I Need?

Feb 4, 2008

I have spent so much time on this but I cannot get it return only those rows where "Sorter" is unique and rate is the lowest for that group (Sorter)The table looks like this:Sorter Lender Loan Rate Price APR101 1 $49,999.00 5.250% -0.450% 6.256%101 2 $49,999.00 5.500% -0.875% 6.344%101 3 $49,999.00 5.750% -0.750% 6.486%101 4 $49,999.00 5.875% -0.893% 6.536%102 2 $100,000.00 5.250% -0.560% 6.070%102 1 $100,000.00 5.500% -0.875% 6.169%102 3 $100,000.00 5.750% -0.750% 6.308%103 3 $125,000.00 5.250% -0.560% 6.036%103 2 $125,000.00 5.500% -0.875% 6.134%What I want to select and what I am looking for would look like this:Sorter Lender Loan Rate Price APR101 1 $49,999.00 5.250% -0.450% 6.256%102 2 $100,000.00 5.250% -0.560% 6.070%103 3 $125,000.00 5.250% -0.560% 6.036%Any help will be greatly appreciated.Bob

View 7 Replies View Related

Select Last 4 Rows Of A Table

Dec 17, 2004

Is there any way to get the last 4 rows which have been entered into the table?

Thank You.

View 2 Replies View Related

Queries :: Select All Rows Except Last

Jan 22, 2015

How I might select all the records within a query except for the most recent one? I have an AutoNumber ID field and a date stamp to use , but I can't figure out how to exclude just the biggest record.I am trying to run an update query on the After Insert Event, so that when the user inserts a new record it will mark down similar older records as 'superceded'.

At the moment I can select all the records, and I can select just the largest one, but I can't seem to take one away form the other. Here is the SQL in it's current state:

Code:

UPDATE [Personnel-Qualifications] SET [Personnel-Qualifications].[Superceded?] = True
WHERE ((([Personnel-Qualifications].PersonnelID)=[Forms]![Personnel]![PersonnelID]) AND (([Personnel-Qualifications].QualificationID)=[Forms]![Personnel]![Child21]![qualificationID]));

View 1 Replies View Related

Modules & VBA :: Select Rows From Different Reports

Apr 9, 2014

Im working on a DB with multiple tables. My DB consists in a lot of tables, each one for a different element and his specifications (e.g.: transmitter, sensor, relay). The user can create loops selecting different elements (All the elements of the same loop have the same Loop ID).

I want that when the loop is finished the user can select one of the loops he has create and see all the elements and specifications he has selected for this loop. The problem is that when I want to show in a form or report all the elements the user has selected before I cant select each different element from his table and show in a form or report.Until now I have this code in a form to select an element from a report and show it, but it doesnt work very well.

-) List3 is a list box in my form where is the list of elements to select.
-) Boton1 is the button in my form to open the report when the element is selected
-) Transmitter Specifications is the report with the list of elements and his specifications.

Option Compare Database
Option Explici
Private Sub boton1_Click()
On Error GoTo Err_boton1_Click

[code]....

View 1 Replies View Related

Queries :: Query To Run Before Report Based On Criteria Based From Two Combo Boxes On Form

Mar 20, 2013

I have a report that gets its data from a query. I need the query to run before the report based on criteria based from two combo boxes on a form.

View 3 Replies View Related

Query That Excludes Rows With Criteria In Multiple Columns

Jun 20, 2013

I am new to Access and have been hitting a wall and seem to be finding nowhere that has this same type of task.

I have a table(Table 1 ) with 3 columns...

Table 1

I am trying to run a query that returns Table 1 but excludes rows that meet multiple criteria. I need to return rows that do NOT contain the combination of criteria below

Criteria

1) Lot Number - Left([Lot Number],2) = "PT"
2) Transaction Desc. - "Put-away"

Basically, i want exclude a "Lot number" starting with "PT" IN COMBINATION WITH a "Transaction Desc" of "Put-away". The goal is for the query to return ROW2 and ROW3 and exclude ROW1.

ROW1 would be excluded from the query result because it meets both criteria.
ROW2 and ROW3 would be included because it does not fully meet all criteria.

View 3 Replies View Related

Query With Rows Based On Date Range?

May 23, 2005

Hi everyone, I am hoping to learn something new about access today. What I need is to be able to run a query that gives me rows of data based on paramenters that I specify. For example, I will query this all just on one table and I want to come up with an output that is in a nice format as follows:

Parameter..........................Member Count
01/01/04 thru 01/20/04...............298
02/01/04 thru 02/20/04...............287
03/01/04 thru 03/20/04...............301
04/01/04 thru 04/20/04...............254

And so on, usually for a calendar year.

Basically each member has an effective date, like member A might have 01/15/04 effective date and member B might have 01/02/04 effective date. I need to capture the count of members by month based on their effective date range. I would like to do it all in one query like above instead of just running a query for January, then February, then March, so on.

Is there a way to do this? Right now I am just running a query and getting one member count at a time and copying that number to an excel spreadsheet. it works okay, but is time consuming. I would rather semi-automate things for me. Any ideas?

Oh and I am new to access, by no means an expert, so be gentle with me.

Thanks,
Hanna

View 2 Replies View Related

Filter Out Rows Based On Number Of Characters

Nov 23, 2005

I have an address database where people have been allowed to type in any characters they want in place of just leaving a missing field blank. For instance the Zip code was not a required field (don't as me why because I don't know. It just wasn't) so over the years when the person entering the data didn't know what the zip code was they would put a ?, a 0, a 000 or a period or what ever else they could think of at the time.

I would like to add a filter in my query where I could eliminate any thing with less then a certain amount of characters.

I thought something like this would do the trick

Zip: IIf(Len([V_ZIP]<5),[V_ZIP],"0")

But I am getting a data type mismatch in criteria expression. Any ideas of what I am doing wrong?

View 4 Replies View Related

Trying To Update Rows Based On A Count Variable

Sep 1, 2006

Apologies if this is a basic question. Here's my situation:

I'm trying to update rows in a table based on a count of items in the same table. The table in question contains order line items. On each line item, I'd like to store the total number of items attached to that order (because it affects how the individual line items are processed).

I have a query that seems like it should do the trick, but Access doesn't like it:

UPDATE sales AS S1 SET S1.EXPC = (select count(*) from sales S2 where S2.order_id = S1.order_id AND S2.product_code = "EXPC");

Here's the error I get:

Operation must use an updateable query.

Thoughts?

View 5 Replies View Related

Reports :: Hiding Rows Based On Cell Value

Aug 21, 2013

I have generated a report with my entire list of personnel, and I have created a column that generates thier age based of another column using this:

=DateDiff("yyyy",[Birthday],Now())+Int(Format(Now(),"mmdd")<Format([Birthday],"mmdd"))

Now my question, im trying to hide the rows of those who age is older than 26. If thats not possible maybe highlight the entire rows of those under 26, i used conditional formatting to highlight the age, but not the entire row.

View 1 Replies View Related

Removing Rows From A Query Based On Date?

May 11, 2015

I have a query that produces a set of rows that contain product IDs and dates (sent). What I want to do is filter out rows that share IDs with another row such that I keep only one row which has the most recent date. As an example my query might contain the following two rows:

DATE ID
01/01/2015 1
02/01/2015 1

What I want to do is filter my table and under the condition that ID #1 appears more than once only keep the row with the most recent date.

I'm unsure what the easiest way to do this would be (or how to do it at all).

View 2 Replies View Related

Combine Datatable Rows Based In Common Value

Nov 27, 2012

i have been trying to combine data from 2 different sources, to make unique rows: here it is my situation Data in DGV already in dgv, Unbound:

column1 | Qty
"Sugar", 100
"Salt", 100
"Color", 200
"Malto", 150

Data in datatable:

column1 | Qty

"Sugar", 80
"Salt", 60
"Apio", 25
"Lemon", 60
"Color", 60

So i want a control that matches the column1 in datatable against DGV.Column1, and if value matches only add second column value and if not, then make a new row in DGV.
Final decided outcome:

column1 | Qty|Qty2
"Sugar"| 100 | 80
"Salt" | 100 | 60
"Color"| 200 | 60
"Malto"| 150
"Apio" | | 25

View 1 Replies View Related

General :: Auto-populating Rows Based On Primary Key

Jul 24, 2012

I have an infopath form, which people in my company can fill out to order parts. The form is linked to an Access database. The primary keys for the database are the Order Number and the Line Number (where the specific part info is in the system). The form also takes info about who entered the order, when they entered it, etc.

My problem is that while the form will be used for only one order, it may be used to order multiple parts. So the infopath form has a repeating section with a table where they can enter multiple line numbers and part names, etc.If I use the form to enter just one part, everything works great. But when I use the repeating section to add multiple parts, the information specific to the repeating section is added to the database but the rest of the information (who entered, when the entered, etc) isn't.

My intial idea was that since the first part is entered correctly and the subsequent parts are missing some information which is already in another line in the database. Maybe if there was a way to pull the information from another line into the lines with missing info within access would solve my problem. So basically automatically populating the rows with matching Order Numbers with the information that is missing.

View 7 Replies View Related

Getting Data From Rows To Columns Based On Common Fields

Jul 30, 2013

I have a big Excel file with payroll information about employees. Per employee per date, there are a couple of rows with mostly identical data (such as the employee's home address) but 2 differences: one will have paycode A with amount B, another will have paycode C with amount D, etc. I want to simplify the file to have 1 row per employee per date: in the example given that row would have paycode A with amount B as well as paycode C with amount D, in 4 separate columns.

I think I can technically solve this by creating Excel files per pay code/amount, and then linking them together by person and date, 1 by 1, through Access. This is feasible because there aren't that many different pay codes. But still, I was wondering if there was anyway to solve my problem in Access itself.

View 1 Replies View Related

Queries :: Identifying And Combining Rows Based On Matched Fields?

Jul 10, 2013

I have two tables. One table is a list of classes with the number of enrolled students:

Class............StEnrolled
English 1A........6
English 1B........12
English 1C........20
English 1D........25
Reading 1.........4
Reading 2.........15

And the other table is a list of "combined" classes (meaning they are, essentially, the same class and should be counted as such):

Class...........CombinedWith
English 1A.......English 1B
Reading 1........Reading 2

Using the first table, I currently generate a query (and build a report) that displays class enrollment levels. What I need is for this query to identify combined sections from the second table and display them as such:

Class........................StEnrolled
English 1A/English 1B........18
English 1C.......................20
English 1D.......................25
Reading 1/Reading 2..........19

View 7 Replies View Related

Eliminating Duplicate Rows In A Query Result Based On One Column

Apr 22, 2014

I have a query based on 2 tables, joined on Memberid, the result showing :

Table1 Table1 Table1 Table2 Table 2 Table2
Category Association Memberid CustomerName E-mailAddress MemberID

Board Member(Lookup,integer) SAMGA(Lookup,integer) 44 Smith smith@abc.co.za 44
Board Member ADHTY 44 Smith smith@abc.co.za 44
Grower SAMGA 44 Smith smith@abc.co.za 44

I only want to show 1 row, based on the duplication of E-mail address. I know i should be using the row_number function, but cannot get to the result I want.

View 4 Replies View Related

Access DB To Populate From XMLS In Proper Rows Based On ID Number

Dec 19, 2011

I have an access DB.I have an XLSM Data Sheet.In the XLSM I have A few Rows with Fields.In the Fields I have a few matching fields as in the Access DB.I also have a few extra fields that i want to add to the Access DB

I want the new fields of the ADB to Populate from the XMLS in the proper rows based on the ID number in the ADB.

View 5 Replies View Related

General :: Update Table Based On Form - Create Multiple Rows

Apr 15, 2014

I have a table with the following columns: Task, Visa type, time it takes to perform the task. There are several taks that are performed for all visa types. I want to create a form to enter data to the table in which for the field visa type I have a list box that can allow multiple values, however, I do not to create a single line with the task and on visa type all the types of visas selected. I want to create a line for each type of visa with the information introduced.

I don't know if this is possible, the reason for which I want for the form to create several rows depending on the visas types is because then I have a query that sums all the types of visas. Can this be possible? I don't want the people to introduce manually directly to the table the data and also that for the same taks they have to enter manually 50 rows with values. I want it to be more simple and easier.

View 3 Replies View Related

Reports :: Conditional Formatting - Rows To Be Of Specific Color Based On Value In 1 Field

Jul 24, 2014

I have a report that I would like to have the rows be a specific color based on the value in 1 field on the row.

I have attempted to use conditional formatting but it will not work (IE, I can get font color to change, but not field boxes to have color).

The field is labeled [text144] based on the value in the field (1,2, or 3) I would like the field to be a different color.
i.e.
3 = green
2 = yellow
1 = red

View 4 Replies View Related

Select Top X Amount Criteria.

Jul 14, 2007

I'm ok with Parameter Queries now, but I'm stuggling for the certeria to select say the top 20 records for a list. This would be based on a number, say amount spent.

Any help?

View 3 Replies View Related

Criteria For Select Query

Aug 27, 2007

Hello,

I am struggling writing criteria that is based off of multiple combo boxes in a search form. I basically have a form setup in several pages the first page being a search page. This page consists of three combo boxes which are populated from the tables. These three boxes are all related. The way the search is setup at the moment is if the combo boxes are Null then they report all the data in the fields but if something is selected then the query gets requeried and displays the data based on that criteria.

What I need to have it do is if it is Null report everything but if something is selected in the first box that selection will also be apart of the second criteria and third criteria.

What I have written at this time is;
First Box:
IIf(IsNull([Forms]![FormName]![Combo1]),[Data1],[Forms]![FormName]![Combo1])
Second Box:
IIf(IsNull([Forms]![FormName]![Combo2]),[Data2],[Forms]![FormName]![Combo2] )
Third Box:
IIf(IsNull([Forms]![FormName]![Combo3]),[Data3],[Forms]![FormName]![Combo3] )

My intentions are too write something that allows the criteria to use the other values in each combo box. The problem I have is it keeps spitting an error out at me which says I have the wrong number of arguments.

Here is what I am trying to accompolish.

PsuedoCode:

If (Combo1 =Null) {
Select all values of Data1
Else {
Select all values of Data1 with match value of Combo1
}
If ( Combo2 = Null) {
If( Combo1= Null){
Select all values of Data2
}
}
Else{
Select all values of Data2 with matching value of Combo1 and Combo2
}
}


Any help will be greatly appreciated.

Thanks!

View 3 Replies View Related

Report Design Response Is Slow - Based On UNION Query That Returns 12K Rows

May 20, 2005

I have a front end that is connected to three back end files. The front end is on my local computer while the back end files are on a network drive.

There are a lot of calculations that go into the queries and intermediate queries. For a report, I have based it on a UNION query.

But when trying to design the report it takes about 45 seconds just to do any one thing, e.g.;
- Add Groupings
- Add Grouping Headers//Footer, sorting option
- Add bound textbox
:eek:

Needless to say this is very annoying.
:mad:

The union query itself runs fine (takes about 15 seconds to run) and returns about 12,000 Rows. The union query looks like this (I changed the field names to make it read easier, hopefully);

SELECT a1, a2, a3, a4, a5
FROM qry_A;

UNION SELECT ALL a1, b2 AS a2, b3 AS a3, a4, a5
FROM qry_B;

UNION SELECT ALL a1, c2 AS a2, c3 AS a3, a4, a5
FROM qry_C;

UNION SELECT ALL a1, d2 AS a2, a3, a4, a5
FROM qry_D;

UNION SELECT ALL a1, e2 AS a2, a3, a4, a5
FROM qry_E;

UNION SELECT ALL a1, f2AS a2, tblG.f3 AS a3, tblG.f4 AS a4, a5
FROM qry_F;

One solution I came across when searching the forums was to use an Append Query to append the query results to a table and base my report on that. This does indeed fix the problem.

But what I was wondering if it was is my query design that is causing it to be slow or is it just the fact that I am returning 12,000 rows?
:confused:

In case it matters, I wanted to mention that I can’t use the report wizard to create the report. When I select the union query, the fields will be showed for awhile then they just disappear. That in and of itself doesn’t cause any trouble since I am creating the report using the design view and not the wizard.

View 7 Replies View Related







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