How To Choose Field Based On Criteria

Jun 1, 2007

Hi,

I am building a database that calculates freight costs for shipments.

I have one table that has order data with fields such as [Order Number], [Origin], [Destination], [Service Level], [Weight].

The service level is one of 4 values: PRE 9, PRE 12, NEXT DAY, NEXT DAY +1.

The origin and destination use country codes such as BE, AT, CZ, PL for Belgium, Austria, Czech, and Poland respectively.

I also have rate sheets from carriers such as DHL and UPS and they provide their rates in the following format (numbers are made-up as real rates are confidential): [Origin], [Destination], [Service Level], [0 to 0.5 kg], [0.5 to 1.0kg], [1.0 to 1.5kg], [1.5 to 2.0kg], etc all the way up to 30kg. The rate is then in the appropriate column and the row gives the origin-destination-service level combination.

(sample freight rate table uploaded as zipped excel sheet in attachment)

I need to return the rate from the appropriate row based on the [Origin], [Destination] and [Service Level] fields (easy enough), which is easy enough.

The hard part is selecting the correct field to return. I tried usign a Choose expression but Access rejected it saying it was too complex (maybe because too many choices?).

So I'm stuck. And working towards a deadline... :-)

Can anyone help please?

Many thanks,
Martin.

View Replies


ADVERTISEMENT

Is It Possible To Choose No Criteria On A User-defined Criteria Form?

Sep 15, 2005

I created a form that allows the user to choose the criteria that they want to see on a report using =Forms!formname!controlname in my query. It works great but I want to also allow the user to choose nothing and return all records instead of limiting them to choose just one type of record. Is this possible? Before I created the form my query had the [Enter parameter] on one criteria line and [Enter parameter] Is Null on the next criteria line and that was working great for my use but I need to create a simple form for other users.

View 1 Replies View Related

Using IIF Criteria To Choose Between Two Different Like Selects

Aug 26, 2014

I am setting up an Access database for a small school. The database contains a record per person. When we get a duplicate lastname field we set a family_id field to lastname followed by a number.

So for example the first Smith family needs to family_id. But the second Smith family gets a family_id of smith1. To select an ordered list of Families I need a query that will use the family_id if it is set and if not use the the lastname to collect family members.

My query uses a presorted table, CurStuByGrdTbl , of current students to produce the families directory by grade and alphabetized.

The WellSchoolCommunityAll table is the entire database. So if the student entry has a valid family_id, matching pattern "*#" then

I perform a Like with family.id otherwise I perform a Like with lastname.

This query gets me nothing, no records.

IIf(([CurStuByGrdTbl].[family_id]="*#"),[CurStuByGrdTbl].[family_id] Like [WellSchoolCommunityAll].[family_id],[CurStuByGrdTbl].[lastname] Like [WellSchoolCommunityAll].[lastname])

View 4 Replies View Related

Update Query To Choose Criteria

Mar 2, 2007

Hello, i was wondering if you could help.
I want to run an update query, taht updates prices in a table. But i would like to be able to choose the criteria when the query runs, for example a message box appears, that will allow me to enter a certain amount for the prices to change by. Could someone guide me on how to do this? thankyou, its much appreciated

View 3 Replies View Related

Tables :: Autopopulation Of Field From Another Table Based On Another Field Criteria

Dec 5, 2012

I have a main table which is autonumbered on unitid, I have another table which is linked via the unitid which holds items purchased for the main table, so the second table is a subform of the suppliers and will have multiple entries of the same unitid. What I would like to do is when an item is entered into the second table, check the main table to see if it exists, if it does populate the unitid field with the unitid from the main table, and if not exist create a new record in the main table with the next unitid number.

This in essence is what I want, bearing in mind that the tblinvoices is a subform and the tblmain is not open.

If ([tblinvoices]![Unit] = [tblmain]![Unit]) Then
[tblinvoices]![UnitID] = [tblinvoices]![UnitID]
End If

View 3 Replies View Related

Criteria Based On The Value In Another Field

Feb 15, 2006

Hey guys, apologies in advance for a question which you may have answered many times, I have searched the net, my textbook and these forums but to no avail.

I have a table, 'tblStock'.

I have two fields within this table, 'Stock Level' and 'Minimum Stock'.

I want to run a query on this table, finding all records where the value in 'Stock Level' is LOWER than the value in 'Minimum Stock'.

How would I go about setting up this query? What criteria would I type? I have tried typing <"Minimum Stock" in the criteria for 'Stock Level' but it didn't work.

Thanks in advance... this will be a big help. :)

View 7 Replies View Related

Criteria Based On Value In Another Field

Apr 3, 2012

I have a query in Access with the following fields (grouped):

"Name" "Facility" "Number of Visits"

I want to limit the query to only pull those names that have at least one visit to a specific facility (let's say facility "A"), but I also need to see all of the other facilities that those who visited Facility A visited. So in this case "= "A"" in the criteria section of the Facility field wouldn't work. I think I need to plug something in the criteria section under the Name field, but I am not sure what.

View 1 Replies View Related

Updating A Field Based On A Certain Criteria

Nov 6, 2006

Is there a way in a query (using SQL) to go to the first record to update a field based on a criteria ?
For example if my amount field shows two amounts for $300.00 I want to go to the first record that has $300.00 to update a field in that record.

Is that possible?

View 9 Replies View Related

How To Set Query Criteria Based On # Of Characters In A Field

Sep 15, 2005

Maybe it's the day's 'brain drain', but I need to set a criteria in a query whereby it will select answers in a field that are a specific number of characters in length.
i.e., answers that are 5 digits long (without knowing any of the digits)

Russ

View 2 Replies View Related

Trouble Extracting Field From Table Based On 2 Criteria

Jun 30, 2005

Hi all,
Been pulling my hair out about this for a while, so i hope someone's feeling kind:


http://www.agga.dsl.pipex.com/pics/AWF01.gif

I'm using the BHRefPrefix to build part of a reference number. The Principal and Site exist on a separate form, and i need to use both as criteria in order for the correct BHRefPrefix to be returned.

I sort of get it working using two joins, but it doesn't let me add any new records. I've tried straight queries, queries with DLookup expressions, and i just can't get what i need.

Pete

View 3 Replies View Related

Queries :: Sum Field Based On Criteria - Return 0 If Not Met (AC2007)

Dec 6, 2013

I have two tables of data. One contains balances for a set of accounts (one unique balance per account, per date). The other contains transactions for a subset of the accounts (multiple records - or possibly none at all - per account, per date)

I'm trying to write a query to return the sum of the transactions from the Transaction table, for each unique account + date combination which is present in the Balance table.

Here is my SQL :

Quote:

SELECT tblBalances.BalDate, tblBalances.AccountID, Sum(tblTransactions.Amount) AS SumOfTransactions
FROM tblTransactions RIGHT JOIN tblBalances ON tblTransactions.AccountID = tblBalances.AccountID
WHERE (tblTransactions.TransDate=tblBalances.BalDate)
GROUP BY tblBalances.BalDate, tblBalances.AccountID;

This works fine with one major problem; if there are NO transactions for any given account + date in the Transaction table, I get no record for that combination in the dataset.

What I need is for the query to return a 0 in those situations (i.e. I should have as many records in my queried dataset as there are in my Balances table, but SumOfTransactions may be 0 for some of those balances)

I've tried the following but it has no effect on the outcome :

Quote:

SELECT tblBalances.BalDate, tblBalances.AccountID, Nz(Sum(tblTransactions.Amount),0) AS SumOfTransactions
FROM tblTransactions RIGHT JOIN tblBalances ON tblTransactions.AccountID = tblBalances.AccountID
WHERE (tblTransactions.TransDate=tblBalances.BalDate)
GROUP BY tblBalances.BalDate, tblBalances.AccountID;

Quote:

SELECT tblBalances.BalDate, tblBalances.AccountID, Sum(Nz(tblTransactions.Amount,0)) AS SumOfTransactions
FROM tblTransactions RIGHT JOIN tblBalances ON tblTransactions.AccountID = tblBalances.AccountID
WHERE (tblTransactions.TransDate=tblBalances.BalDate)
GROUP BY tblBalances.BalDate, tblBalances.AccountID;

View 4 Replies View Related

How To Construct Dynamically A Table Field Based On Query Criteria.

Sep 13, 2007

Hello all,

I have a temporary table with Yes/No fields (F101,F102,F103,....etc).
In another table i have a field called ProductCode with values (101,102,103,....etc)
Is it possible to append(or update) the records of the temp table with criteria on "F" &ProductCode field? (For example if ProductCode=101 then F101 sets to yes)

Thank you in advance.

View 4 Replies View Related

Queries :: Give Remarks With Number Based On Criteria Field

May 12, 2014

I want to get remarks as like this i have a query which is showing the total of different fields suppose the total is 77 and I want to give a crietria field by name of net level which shall work like this ..

if the number is from 0 to 33 then then the result should be C-1
if from 33 to 40 then C-2
if from 41 to 50 then C-3
if from 51 to 60 then B-1
if from 61 to 70 then B-2
if from 71 to 80 then B-3
if from 81 to 90 then A-2
if from 91 to 100 the A-1

View 8 Replies View Related

Modules & VBA :: Populate A Field With A Sequence Number Based On Two Criteria?

Sep 11, 2014

I am trying to get the max of an integer field if the ProjectNumber field is equal to the ProjectNumber field in the current record. I have used code similar to the one below before but it was on a date field, then add one.

Me.RevisionNumber = Nz(DMax("[RevisionNumber]", "dbo_ProposalLog", "[ProjectNumber] =" & Me.ProjectNumber), 0) + 1

The ProjectNumber field is a text field.

View 6 Replies View Related

Choose In Combo Display In Field

Sep 1, 2006

Hi

Can anyone create a form with a combobox where you can select a form and this form will display in an static area.
Then you can choose another form in the combobox and it will display in the same spot.
the forms that will be displayed are exactly the same size.

This would help me very much

Thanks

Mikael

View 1 Replies View Related

Forms :: DLookup - Unbound Field To Auto Determine Pricing Based On 3 Criteria Chosen

May 28, 2014

I have a table that consist of pricing for different types of products:

Table name: Costs

ID TYPE EastNew EastRenew WestNew WestRenew
1 500 4100 1000 4400 900
2 501 4100 1000 4400 900
3 600 3400 900 4600 1200
4 700 3700 1300 4900 3300

I have a form that consist of many fields that the user needs to manually input data. 3 fields on that form are the criteria i need to determine which pricing to use back on the table. The first field, which name is LTYPE, is a combobox that the user needs to choose as its type (i.e 500,501,600,700). The second field, which name is EastCoast, is a checkbox (Yes/No) that tells me if it's East Coast (East = yes and West = No). The third field, which name is NewRenewal, is a combobox that the user chooses NEW or Renewal).

Example 1, if the user chooses type 501, checkbox is YES for East, Product is NEW. Then the pricing is $4,100

Example 2, if the user chooses type 700, checkbox is unchecked for NO (which is West), Product is Renewal. Then pricing is $3,300

I would like the unbound field to auto determine the pricing based on the 3 criterias chosen. I read around the forums that Dlookup would be the function for this, however, i tried many times but it did not work.

View 6 Replies View Related

Forms :: Button Click Event To Choose Between Forms To Open Based On TextBox Input

Jun 7, 2013

Making a small database, Got 1 Table.

1. ContactDetailTable

Got 3 forms.

1. ContactIDForm
2. ContactInfoForm
3. NewContactFrom

In ContactIDForm it contain 1 textbox name 'TextBox' with Button Name 'Btn'

In ContactIDForm there is only 1 Text Box ContactIDTextBox and 1 Button. User Enters ID in TextBox and On Button Click Event it should check data from TextBox in Table name (ContactDetailTable) in field ContactID and if there is record matching, ContactInfoForm should Open else NewContactForm should open with ContactIDTextBox value in it.

View 10 Replies View Related

General :: Database To Automatically Choose Option Depending On Calculated Field?

Aug 10, 2015

I have an option button for a field [Fully Paid] (Yes/No) in my LoanT and i want to know if it's possible for my database to automatically choose an option depending on a calculated field

(Calculated field from another query) = [Outstanding Balance]

Say... if [outstanding balance] is = 0 or negative (refundable), then Yes should be On, if not it should remain No/off so that i wouldn't have to go over every record and manually choose the option

The option button is very useful when i want to display loans which are Paid and/or still active. How do I go about this?

View 14 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

Forms :: Include Check Boxes In Interactive Access Form Allowing To Choose Output Field

Jun 27, 2013

Including check boxes (representing the query fields) in an interactive access form, in order to decide which fields should be visible.

I think the solution is building an invent in VBA for each check box, however I'm not an expert in Access VBA and don't know how to write the code.

In the example that I've uploaded, in the Form1, when I run the query, all fields are displayed, i.e. VENDOR, REGION, CUSTOMER and MATERIAL are displayed. How can I manage it in the form with a listbox to display only the REGION or MATERIAL for instance.

View 4 Replies View Related

Query Based On 2 Out Of 4 Criteria?

Aug 18, 2005

I have table with filed with jobs that our IT’s have done for that day, the table is updated daily, based on my table I have created my query, I have set some criteria for some fields though, as follow:

Month = [Forms]![DailyWorkForm]![commonth]
Year = [Forms]![DailyWorkForm]![comyear]
ITName = [Forms]![DailyWorkForm]![comit]
Day = [Forms]![DailyWorkForm]![comday]

on my form I have commonth, comyear, comit, comday and a command button that will open a report based on the query which will be based on my 4 combo boxes on my form, ok I hope I didn’t make you all really confused, this is the question what if the user inputs on 2 combo only, meaning that if month = may and year = 2005 and left ITname and day empty, I still want the query to run, how can I do that?

Thanks a lot.

View 8 Replies View Related

Randomizing Based On Criteria

Dec 17, 2013

I have created a db where I need to run a report based on randomizing. Basically there is a table ORDERS that is updated daily with orders from clients.

Table structure is:
ORDER ID (autonumber).
CLIENT.
ORDER.
Quantity,
Date.

Sampling criteria is:
if number of Orders is from:
1-10 show me 90% of them
11-20 show me 85 % of them
21-100 show me 51% of them etc

I did found this code for the randomizing with autonumber:

Private Sub cmdSelect_Click()
Dim SQL As String
Dim sWhere As String
Dim iCount As Integer
Dim i As Integer
Dim j As Integer
Dim iSelectHowMany As Integer

[Code] ...

How to integrate into this code my sampling?

View 8 Replies View Related

List Box Based On Criteria In Same Row

May 2, 2014

I have a table where the columns are team1, team2 and winner. Team1 and team2 are comboboxes that show all the teams in Team table. After I pick the team1 and team2 in a row I want to make a listbox that shows only those two teams as options for the winner.

View 3 Replies View Related

How To Get An Automatic Entry Based On Criteria

May 9, 2007

My database tracks individuals qualifications. These qualifying scores relate to Unqualified, Expert, Advanced etc. What I want to do is add a entry into my roster table which will have the qualification score.
I then want to have the score and actual qualification (Advanced, Expert, etc) in a Report.
The qualification type is a range (less then 30, 31-40, 41-50), and I think that I will need a BETWEEN statement. What I am not sure of is how to put this together to make it equate the number with the equivalent word in a report.

Thanks
the brewmeister

View 3 Replies View Related

Move To A Different Table Based On Criteria

Apr 28, 2005

I've got a database that pulls from a table. One of the options on the table is pending or complete. Right now, there are over 1000 records because they are all stored in the same record. I'd like to move the completed items to a different table.

Can this be done? If so, what steps do I need to take to do this?

Thanks!

View 3 Replies View Related

Query Two Fields Based On One Criteria

Aug 21, 2005

Hi all,

I am endeavouring to filter a form based on the position of an individual.
I would like the users to be able to select their position and then any record where there is a match in the "Primary Responsibility" field or the "Secondary Responsibility " field will be displayed.

I have an underlying query that is populated by a combo box on an unbound form.

This has worked when generating reports for individuals but I cannot get the required result when using the form.

Thanking anyone in advance who can assist me with this.

Regards,

Rod

View 2 Replies View Related







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