Queries :: Create A Field Using IIF Function

Jan 28, 2014

I am trying to , create a field using the IIf function that will display a $250 bonus for agents every time they sell a car for at least $20,000. Otherwise, the function will return a 0. Name the field Bonus. I put in Bonus: IIf(SalePrice >= "20,000" Then + "250",True, 0) and it is saying that I have an improper syntax.

View Replies


ADVERTISEMENT

Queries :: Create A Statistics Function On A Database

Jun 15, 2014

I am trying to create a statistics function on a database. The idea is that the user will enter a start and end date and either search for all records during that date range or select a client from a combo box and only view records for that client during the selected dates.

After doing quite a bit of searching, it seems that I should be using a wildcard in the criteria however I cannot get this to work. The code I have been playing with is:


Code:
=Nz(Forms![Statistics]![ClientCombo] ,"*")

I have changed the "*" to a specific client number and if the combo box is left blank, results are shown for that client only and if a client is selected from the combo box then the selected client is shown. The only thing I cannot get it to do is show all entries if the combo box is left blank.

View 2 Replies View Related

Queries :: Query Or Function To Update Another Field Value

Nov 21, 2013

Would I use an update query or function to complete my task?

Task: Automatically update [Status] based on DateDiff calculation of [RequestDate] and [DueDate]

Issue: [Status] can be one of 6 values, the user can manually select Review or Completed.

[Status] values: Review; Completed; Due in 24; Due in 24-48; Beyond 48; Over Due

Query: Below is the query I just started to ignore the calculation if either Review or Completed exist.

Expr1: IIf([Status]="Review",[Status],IIf([Status]="Completed",[Status],DateDiff('d',[RequestDate],[DueDate])))If the value from above DateDiff equals to the below, I want to update the [Status] field to the [Status] value.

Due in 24 = (0-1)
Due in 24-48 = (2-3)
Beyond 48 = (greater than or equal to 4)
Over Due= (-1)

View 14 Replies View Related

Queries :: If Function - Calculations Based On Field

Dec 15, 2014

I would like queries to do some calculations for me based on a field. The field in the form is a combo field and the user can choose either 1, 2 or 3. Based on the selection, I would like queries to generate some numbers for me.

This is what I have in mind but its not working.

Code : TEST RESULT: If([tlkpTEST].[RESULTID])=1, ([tlkpTEST].[RESULTID])*2, 100)

View 2 Replies View Related

Queries :: DateAdd Function Using Existing Field Values

Nov 26, 2013

I have a query in design view that consists of two calculated fields at the moment. One of the calculated fields is supposed to add one year onto a value from another date/time field called "Last_Date."

The expression I've written in the "Field:" box in Query design view is

Expr 2: DateAdd('yyyy',1,[Last_Date])

When I try to run the Query it doesn't work! Access just prompts me to enter a parameter value for Last_Date.

View 1 Replies View Related

Queries :: How To Create A Quarter Field In A Table

Jul 12, 2013

I have a Date field in the format X/XX/2012 for all my records.

I want to create a field that labels each record according to its quarter. So if a date is 3/29/2012, I'd want the corresponding field entry to be: Q1 2012. If it's 3/29/2013, I'd want it to be: Q1 2013, etc.

I guess I would run an update query, but I don't know how to build the proper expression in order to update my table with a new field.

I have figured out how to create a quarter #, but I actually need output in the format mentioned above.

View 10 Replies View Related

Queries :: How To Create A New Field Containing Only Names Of The Wards

Apr 17, 2013

I have two fields.

Field 1 contains the names of local authorities

Field 2 contains the names of electoral wards - preceded by the names of the local authority area and " - "

I want to create a new field containing only the names of the wards.

How can I get Access to read the LA names from Field 1 and strip them and " - " from Field 2 and post the resulting text in a new field?

As LA names all vary in length simply stripping out first ?? characters or words doesn't work.

View 1 Replies View Related

Queries :: How To Create Total Cost Field

Oct 27, 2014

I have a table called Price list, and in it I have two fields, one called Service and The other called cost. The services are listed and their matching prices are listed beside.

In another table called appointments, when making an appointment, I have linked the information so that I can choose from a dropdown from the price list table, under Service type.

I need to be able to create a receipt for the appointment. How can I do that in a query format?

View 1 Replies View Related

Queries :: Create Numerical Sequence Based On Second Field

Aug 30, 2014

Have two tables: Assignment and StudentHeader - they are related by AssignmentGUID

Have the SQL:

SELECT StudentHeader.[Student ID], StudentHeader.GUID
FROM Assignment INNER JOIN StudentHeader ON Assignment.GUID = StudentHeader.[Assignment GUID]
WHERE (((Assignment.[Assignment Type])="Q") AND ((Assignment.[Assignment Number])=2))
GROUP BY StudentHeader.[Student ID], StudentHeader.GUID
ORDER BY StudentHeader.[Student ID], StudentHeader.GUID;

This returns:

Student IDGUID
al003072274
al154636303
al154636463
al595048272
al941626429
am180614426
am750033300
am750033462

I want a third field - Sequence - based on the Student ID and GUID, therefore

Student IDGUIDSequence
al0030722741
al1546363031
al1546364632
al5950482721
al9416264291
am1806144261
am7500333001
am7500334622

View 14 Replies View Related

Queries :: Create Separate Columns From Same Field And Table

Apr 9, 2013

I have 1 table that I duplicated to make 3 tables total. I did this b/c I am trying to create separate columns from the same field and table. The field is Workorder. Each workorder list the workorder number followed by a dash and then code. I am wanting to put all of the workorders with the same code in it's own column.

I have 5 codes that i am searching for. The first column list the workorder and a code (123456789-AD). The second column (123456789-BC). I'm good to this point but my problem occurs next.

The third column i am trying to put 3 types of workorder and it's code in the same column. As follows, (123456789-CD, 123456789-TC, and 123456789-PTC. However, when I do this it takes the results from the 3rd column and applies it to the 3rd column but also the 1st and 2nd column. I tried a UNION query and unless I am doing it incorrectly it does not work.

View 3 Replies View Related

Queries :: Create View (Query) With Only Change In Value For First Field

Jul 16, 2014

Need sorted Query to be used in a Listbox. The attachment shows a made-up view of the objective.

The first column shows the change in value, then blanks for the first column's next rows, until there is a change of value again.

I do something like this in Excel where the first change in value is bolded. This is to make a list box more readable.

View 13 Replies View Related

Queries :: Datatype Mismatch In Criteria Expression Regarding A CDate Function Field

Jun 25, 2014

I have this linked table query from a OBDC and I need to be able to filter out specific dates in that query. The dates in the table were in text format and I converted the dates using the CDate function. I wanted to filter the query to a single date and always I get the Datatype mismatch in criteria expression error.

However, filtering dates does work only when there are other specifications in the criteria fields (e.g. if I specify a date and and name). My SQL code in error looks like this:

SELECT
purch_hist.PUITM AS ITEM,
purch_hist.PUPO AS PO,
purch_hist.PUQTY AS QTY_RECEIVED,
CDate([purch_hist.PURDT]) AS RECEIPT_DATE,
itmcnt.ITBYR AS BUYER,
purch_hist.PUCST AS UNIT_COST,
vendor.NVNO AS VENDOR NO,

[code]...

This query works fine with a non converted date field, however the dates I need are in text format and need to be converted since I do not have permissions to edit the tables.

View 14 Replies View Related

Queries :: Importing Excel Text Field Into A Table - CDate Function?

Apr 28, 2014

I am importing an excel text field into a table. I am then appending the data to another table. I am having a hard time with the Cdate function

Excel Date Field:
YYYY.MM.DD HH:MM:SS

Example Value:
2014.04.21 18:24:30

My Query Code:

NewDate: CDate(Left([DateQ],4)+"/"+Mid([DateQ],6,2)+"/"+Right([DateQ],2))

My Query Result:
4/30/2014

What it should be:
04/21/2014

View 12 Replies View Related

Queries :: Loop To Create New Tables With Unique Field Values

Sep 20, 2013

I have a table - (Table A) that has 2 fields X and Y. I would like to write a query or script to make two new tables based on the unique values found in field X. In other words, all data where field X = 1 would be written to a new table called "1" and all data wehre field X =2 would be written to a new table called "2".I would like this done automatically.

Table A
Field X Field Y
1 a
1 b
1 c
1 d
2 a
2 b
2 c

View 5 Replies View Related

Queries :: Create And Order By Random Number In Query Field

Jan 2, 2015

I'm trying to create a query that generates random numbers for each record, sorts them by that field, then selects the top record. This should randomize the record being selected.

I can use the Rnd([ID]) function which does appear to generate a random number. Problem is that each time I exit the program and come back in, it always selects the same record. When I remove the Top = 1, to show all the records, every row does have a different random number but it does not appear to be sorting by this field.

If I run the query, here is the number I get: 0.98609316349029

Exit the program, restart, and run the query again: 0.98609316349029

If I refresh the query, the second and third time does appear to be random but the first result is always the same. how to generate truly random numbers?

View 7 Replies View Related

Create A Search Function In Database

Aug 13, 2013

I've been trying to create a search function in my database and a " TmprryQryFrLnkFldsCrtn0123456789 " Query has appeared that I cant alter or change.

View 6 Replies View Related

Modules & VBA :: Create Disable Alphabetic Keys Function Based On Case Statement

Jul 31, 2015

Details:
I have a Profile form that tracks the expiration date for each client's various certifications. These dates are set up in the Short Date format in the table design of Access.

Problem:
When a user accidentally presses an alphabetic key while updating an expiration date, an Access error message is triggered. This is confusing to my users as these messages are written in Access lingo. I would rather that nothing occurs at all. I wrote a case statement to disable each letter of the alphabet and applied it to the On Key Down Event for each expiration date control on my Profile form to solve this problem, but this must be applied to 28 separate controls. I would rather call a function that disables alphabetic keys for each date control in my form when called.

Questions:
How do I transform my Disable Alphabetic Keys Case Statement into a function that I can call for each expiration date control? I know that when writing a function certain variables have to be declared and/or initialized.

Also, will I need to create a function to re-enable alphabetic keys or is this unnecessary because the disable alpha keys function will only be called for specific controls, not the entire form?

What I Have Tried:
I have tried copying and pasting my Disable Alphabetic Keys Case Statement into a module to attempt to create a function, but it needs work.

Below I have included 2 types of code:
(1) The original On Key Down code applied to each date control on my form
(2) The same code written as an attempt at a function

Original Profile Form Code to Disable Alphabetic Keys in the On Key Down event for each date control

Private Sub txtCert1ExpDate_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
'All message box text is for me to test the code, not for the user to see
Case vbKeyA
MsgBox ("you pressed the A key")

[Code] .....

View 14 Replies View Related

Queries :: Create A Query On All Queries In Database

Mar 19, 2013

I am hoping to do a report all my queries in my Database.

I have managed to use some sql code to list the queries which is the following:

SELECT MSYSOBJECTS.Name
FROM MSYSOBJECTS
WHERE (((MSYSOBJECTS.Type)=5) AND ((Left([NAME],1))<>"~"));

But i cant seem to get any further i would also like to include the creation date, the description if any, the tables associated with each query, as i know i have a good few queries which maybe duplicates i just want to clean it up.

View 2 Replies View Related

CheckBox Function In Queries

May 17, 2006

I'm looking for someone that knows how to link check boxes on a form to the "show" check-box in a query. Basically, all I'm trying to do is have the end-user tell the query which fields to show in the output. If checkbox "A" is checked on a form prior to kicking off the query, I'd like field "A" to show in the query output...and so on.

Thanks, Paul

View 3 Replies View Related

Queries :: Using If Function For Query

Oct 11, 2013

I have a query driving a report that fills in the on time or late based on comparing the release date to the production due date. The code works except for if we haven't released it yet and the release date is void. I need it to then check versus today's date and then populate the late/on time. But I need this to take a back seat to if both fields are populated. Here is the code I am currently using and I have attached a screen shot of the query with the 2 boxes highlighted in red.

On Time / Late Eng: IIf([Released to Prod]<=[Prod Due Date],"On Time",IIf([Released to Prod]>[Prod Due Date],"Late",""))

View 7 Replies View Related

Queries :: Max Function To Get Only One Number

Jul 21, 2015

How do I use the Max() function to get only one number. And also what do I put in the parentheses?

View 14 Replies View Related

Queries :: Using A Function To Set SQL Criteria

Feb 5, 2014

I am using a function to set criteria in a an query. It reads the selected values from a combobox on a form and passes the appropriate value into the sql criteria.

E.g., the sql criteria is set to : like fnCountry()

And the function fnCountry() is something like;

If SelectedCountry = "All" Then
fnCountry = "*"
else fnCountry = SelectedCountry
end if

This works fine for a single selection (SelectedCountry = Africa) but doesn't work if I try to combine multiple selections into the criteria string.

E.g. SelectedCountry = Africa Or Italy

So the criteria would need to be
Like "Africa" Or like "Italy"

How else can i build this criteria with multiple values?

View 3 Replies View Related

Using The Count Function In Access Queries

Mar 13, 2007

Hi

I have a table which has information the count of students in classrooms around the university and I need to summarize the table by Faculty. Therefore, all I want to do is a count of students for each faculty i.e. Art and Design, Business and Law etc.

The query i put together is: SELECT Count([tbl_Audited Classroom for Week 02].Faculty) AS CountOfFaculty
FROM [tbl_Audited Classroom for Week 02]
HAVING (((Count([tbl_Audited Classroom for Week 02].Faculty))="BAL"));

So when I run the query I get the error message 'Data Type mismatch in criteria expression'. The Faculty field is a text field, so I don't know if that would make a difference.

Can you please help?
thanks

View 5 Replies View Related

Queries :: Max Function In Query By Row Not Column

Apr 3, 2015

I have a table that holds the dates of various approvals for documents.

Approval DatesDocumentID
ApproverA_DateApproved
ApproverB_DateApproved
ApproverC_DateApproved
LastUpdated

In a query, I'd like there to be a column with the date of the most recent approval (max date) for each document. Using the following formula in the Expression Builder gives me the error below.

Code:
Name: Max( [Projects]![ApproverA_DateApproved],[Projects]![ApproverB_DateApproved],[Projects]![ApproverC_DateApproved])

"The expression you entered has a function containing the wrong number of arguments"

How can I get the most recent date a document was approved by any approver?

BTW - I initially thought I could just use the date the record was last updated. However, sometimes people remove their approval. This causes the LastUpdated date to be wrong (for this purpose), since it then reflects the date they removed their approval, not the most recent date that someone gave it.

View 3 Replies View Related

Queries :: Using DateValue Function With Query

Aug 1, 2014

How do I use the DateValue function with a query that pulls data between dates? Here is my code below. I'm getting an error that my expression is too complex or incorrect.

Code:
SELECT IIf([tblAUCodes].[BusinessLine] Like '*CMES*',"CMES",IIf([tblAUCodes].[BusinessLine] Like '*HOUS*',"CMES",IIf([tblAUCodes].[BusinessLine] Like 'CTO',"CTO",IIf([tblAUCodes].[BusinessLine] Like 'Shareowner*',"WFSS","SPS")))) AS LOB, Count(tblPACSTemplate.temID) AS CountOftemID, tblPACSTemplate.Type, DateValue([ApprovedDate]) AS ApproveDate

[Code] ....

View 8 Replies View Related

Queries :: Average Function In Query

Jul 5, 2013

I am currently designing a dashboard for my team which works on projects, I have a main table which has main fields which i use for my dashboard

Project Type,Project ID (Primary Key), Submitted by, Project Start date, Project end date, Status

The tricky part is that the raw data has projects which got started couple of years back some got closed in the previous fiscal year but some are still being worked upon..I was able to put in a where clause to only display projects whose close dates either have null value ( projects which are still being worked) and where the close dates are >= 1/1/2013. My Dashboard needs to have the below fields

Project Type, Count of Projects, Count of Closed Projects, Average days to complete, Count of Active Projects & Average Active days

I was able to get it correct except the last field Average Active days as it is displaying Average no's even against the project type which doesn't have any active projects or where the active project count is zero.

SELECT TblWO.[Operational* Categorization Tier 2], Count([TblWO]![Operational* Categorization Tier 2]) AS [Count], Avg([TblWO]![SLA in Days]) AS [Internal SLO in Days], Count([TblWO]![Closedate]) AS [No Closed Projects], Round(Avg([TblWO]![Closedate]-[TblWO]![Work Order Submit Date Time]),2) AS [Avg Close Days], [Count]-[No Closed Projects] AS [No Active Projects], Round(Avg(Date()-[TblWO]![Work Order Submit Date Time]),2) AS [Active Avg Days]
FROM TblWO
WHERE ((([TblWO]![Closedate]) Is Null Or ([TblWO]![Closedate])>=#10/1/2012#) AND (([TblWO]![Status])<>"Cancelled" And ([TblWO]![Status])<>"Rejected"))
GROUP BY TblWO.[Operational* Categorization Tier 2]
HAVING (((TblWO.[Operational* Categorization Tier 2])<>" "));

View 3 Replies View Related







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