'Sum' Ignoring Minus Figures

Jan 22, 2007

I've been using the following query:

SELECT
[qry_1].Month,
B_Division_Group.Grouping_Name,
Sum([qry_1].Month_Client_Count_from_B) AS Monthly_Count,
Sum([qry_1].Month_Assets_from_B) AS Monthly_Total,
Sum([qry_1].YTD_Client_Count_from_B) AS Yearly_Count,
Sum([qry_1].YTD_Assets_from_B) AS Yearly_Total
FROM
([qry_1] INNER JOIN tbl_branch
ON [qry_1].BranchCode = tbl_branch.BranchID)
INNER JOIN B_Division_Group
ON tbl_branch.BranchName = BDivision_Group.N_Br
GROUP BY
[qry_1].Month,
B_Division_Group.Grouping_Name;

While all monthly and yearly values were positive, the query produced exactly the results expected (i.e. one row of data for each Grouping Name/Month combination, containing the overall totals for each field).

Now, however, some Grouping Names have minus values and the query is showing an extra row (one for positive values, one for negative). It's as if having one or more minus values is being treated as a new Grouping Name/Month combination.

Is Sum() the correct method to use, when dealing with negative values, or should I be using some other function?

View Replies


ADVERTISEMENT

Converting Figures To Words

Jul 6, 2006

Dear all,

I am creating a database which has an invoice printing form. In that I would like to have a column for the total amount in words. I have got a sample module from northwind database. According to that 100,000 is "one hundred thousand" but in my country that is pronounced as " 1 Lakh" and for one million it is 10 lakh, for 10 million it is 1 crore like that. Is that possible to change the code in that module to display the words according to our standards? I am attaching the code with this thread. If anybody can show how to do that...I will be thankful to them..


Thanks


Function ConvertCurrencyToEnglish(ByVal MyNumber)
Dim Temp
Dim Dollars, Cents
Dim DecimalPlace, count

ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "

' Convert MyNumber to a string, trimming extra spaces.
MyNumber = Trim(Str(MyNumber))

' Find decimal place.
DecimalPlace = InStr(MyNumber, ".")

' If we find decimal place...
If DecimalPlace > 0 Then
' Convert cents
Temp = Left(Mid(MyNumber, DecimalPlace + 1) & "00", 2)
Cents = ConvertTens(Temp)

' Strip off cents from remainder to convert.
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
End If

count = 1
Do While MyNumber <> ""
' Convert last 3 digits of MyNumber to English dollars.
Temp = ConvertHundreds(Right(MyNumber, 3))
If Temp <> "" Then Dollars = Temp & Place(count) & Dollars
If Len(MyNumber) > 3 Then
' Remove last 3 converted digits from MyNumber.
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
count = count + 1
Loop

' Clean up dollars.
Select Case Dollars
Case ""
Dollars = "No Dollars"
Case "One"
Dollars = "One Dollar"
Case Else
Dollars = Dollars & " Dollars"
End Select

' Clean up cents.
Select Case Cents
Case ""
Cents = " And No Cents"
Case "One"
Cents = " And One Cent"
Case Else
Cents = " And " & Cents & " Cents"
End Select

ConvertCurrencyToEnglish = Dollars & Cents
End Function


Private Function ConvertDigit(ByVal MyDigit)
Select Case Val(MyDigit)
Case 1: ConvertDigit = "One"
Case 2: ConvertDigit = "Two"
Case 3: ConvertDigit = "Three"
Case 4: ConvertDigit = "Four"
Case 5: ConvertDigit = "Five"
Case 6: ConvertDigit = "Six"
Case 7: ConvertDigit = "Seven"
Case 8: ConvertDigit = "Eight"
Case 9: ConvertDigit = "Nine"
Case Else: ConvertDigit = ""
End Select

End Function

Private Function ConvertHundreds(ByVal MyNumber)
Dim result As String

' Exit if there is nothing to convert.
If Val(MyNumber) = 0 Then Exit Function

' Append leading zeros to number.
MyNumber = Right("000" & MyNumber, 3)

' Do we have a hundreds place digit to convert?
If Left(MyNumber, 1) <> "0" Then
result = ConvertDigit(Left(MyNumber, 1)) & " Hundred "
End If

' Do we have a tens place digit to convert?
If Mid(MyNumber, 2, 1) <> "0" Then
result = result & ConvertTens(Mid(MyNumber, 2))
Else
' If not, then convert the ones place digit.
result = result & ConvertDigit(Mid(MyNumber, 3))
End If

ConvertHundreds = Trim(result)
End Function


Private Function ConvertTens(ByVal MyTens)
Dim result As String

' Is value between 10 and 19?
If Val(Left(MyTens, 1)) = 1 Then
Select Case Val(MyTens)
Case 10: result = "Ten"
Case 11: result = "Eleven"
Case 12: result = "Twelve"
Case 13: result = "Thirteen"
Case 14: result = "Fourteen"
Case 15: result = "Fifteen"
Case 16: result = "Sixteen"
Case 17: result = "Seventeen"
Case 18: result = "Eighteen"
Case 19: result = "Nineteen"
Case Else
End Select
Else
' .. otherwise it's between 20 and 99.
Select Case Val(Left(MyTens, 1))
Case 2: result = "Twenty "
Case 3: result = "Thirty "
Case 4: result = "Forty "
Case 5: result = "Fifty "
Case 6: result = "Sixty "
Case 7: result = "Seventy "
Case 8: result = "Eighty "
Case 9: result = "Ninety "
Case Else
End Select

' Convert ones place digit.
result = result & ConvertDigit(Right(MyTens, 1))
End If

ConvertTens = result
End Function

View 9 Replies View Related

Calculating Finance Figures

Mar 1, 2007

Hi
I would be glad of a little help.
I am creating a c ontracts database and need to keep trak of individual contractors figures.

I set up a contractor and allow the system to only issue orders to a contractor if there monthly balance doe not exceed 1/3 of their total monthly turn over.

My problem is in keeping track of the relevant figures and how I go about this?

Thanks in advance

View 6 Replies View Related

Top 5 Speed Figures Per Entrant

Apr 23, 2007

I have a query which returns each entrant with the speed figures in a descending order for previous races, I wish my query to return the top 5 speed figures per entrant or if the entrant has less than 5 previous runs it needs to return all available data.

I am not VBA literate, so as simple as possible please, thanks.

Freddy67

View 5 Replies View Related

Setting Up A Table For Sales Figures

May 6, 2005

Dear All,
My boss wants me to create a budget report as follows:

Rep Cust ActM$ BudgetM$ VarM$ ActMProfit BudgetMProfit VarMProfit

ActYTD$ BudgetYTD$ VarYTD$ ActYTDProfit BudgetYTDProfit VarYTDProfit


I have a table with the following headings:

Date State Product Prod Code Customer Cust Code Category Jan Feb Mar etc

State has the domain Vic, NSW, Qld
Category has the domain Sales GP

Question 1:

To the field Category, should I either

A: add to the domain actual sales and actual profit? I can past these into the table at the end of each month.

OR

B: set up a separate table for the actual sales and actual profit for the month?

I think A.

Question 2:

Instead of having a separate column for each month, should I either:

A: just have a heading Month and put the figures in that column

OR

B: Have the sales figures in separate columns for each month?

I think A

Question 3:

When I have set up my table correctly, and assuming the answers to my questions above are all "A", I am now unsure how to create a query which will give me the data for the report my boss wants.


Can someone please give me some help?

Thanks
Bon

View 4 Replies View Related

Lookup Multiple Figures Within A Column?

Feb 6, 2007

Hi

Is there a way you could look up multiple number in a query were the column will be a series of numbers/calculations?

E.g.

I would want to look for 13001,13002,13003, in a column where there would be calculation such

13001 * 246
13001 * 269
13002 849
etc
etc

Any help would be much appreciated?

Thanks

Andrew

View 1 Replies View Related

How Do I Create A Table That Contains Figures Calculated From Other Tables?

Feb 18, 2008

Hi,

I have two tables:

Table A provides total sales volume of the UK shoe market from 2000-2007.

Table B provides the sales volume of different shoe manufacturers from 2000-07.

I want a third table created, called Table C. This should look exactly like Table B but instead of sales volume it shows percentage sales that are calculated by using the figures in Table A and B (i.e. [sales volume from Table B/total sales volume from Table A] * 100).

Could someone point me in the right direction please (assuming that such a table can be created, based on a calculation of figures in other existing tables).

Thank you.

View 3 Replies View Related

Sorting By Ignoring × And +

Jan 27, 2007

I have a table of plant names such as

×Mahoberberis
+Crataegomespilus
Iris
Scilla
Hebe
Geranium
Acorus

Note that the multiplication and plus signs are part of the names.

If I sort the table (A-Z) I get

+Crataegomespilus
×Mahoberberis
Acorus
Geranium
Hebe
Iris
Scilla

What I would like to see is

Acorus
+Crataegomespilus
Geranium
Hebe
Iris
×Mahoberberis
Scilla

I am not a programmer so need to be led by the hand, but can anyone see a way of achieving this which I could copy? My simple mind tells me that I have somehow to suppress the × and + during the sort. But how?

View 3 Replies View Related

Ignoring International Characters

Nov 7, 2005

When running a search I would like Access to ignore international characters like á é í ó ú ñ.

For example searching for "Amelia" matches both "Amelia" and "Amélia"

I know this is done in SQL Server by setting it to ignore nonspacing characters.

Can this be done in MS Access?

View 1 Replies View Related

Ignoring Blank Fields

Jan 15, 2006

:confused: I have a Text box on a Form that copies data entered into other Text boxes on the same form.
Sometimes there may be the odd text box that does not have any data in it.
Is there anyway that I can put in code so that the blank text boxes are not copied into the main text box i.e. Only the populated text boxes are to be copied.
Thankyou for any assistance that you can provide.:eek:

View 4 Replies View Related

TransferText Import Ignoring The First Line

Sep 26, 2005

I am currently importing data using the the "TransferText" method in Visual Basic; e.g., expression.TransferText(TransferType, SpecificationName, TableName, FileName, HasFieldNames, HTMLTableName, CodePage)

Per the above description, I can either include the first line as a field name, or as data. Is there any way to simply ignore this data row and start the import from row 2 onwards?

Thanks as always

k

View 2 Replies View Related

Ignoring Rows In File Import

Mar 13, 2006

I am currently trying to import a text file into an Access (2000) Table. My text file has a header line (first record) and a footer line (last record) which I want to ignore when importing. I am sure someone out there would have had a need to do something similar to this in the past. I am wondering if someone can point me in the right direction.

I have tried a few different google searches and nothing promising seems to come back. Mostly just references to check the first line for field headings box.

Any assistance would be appreciated.

View 1 Replies View Related

Query Ignoring 'zero' Catch Sets

Jan 6, 2006

I have a db with two tables linked by a Set_ID field. One table characterizes set information (date, time, location etc) and the other table has records for groups of fish caught in the set. The fish_table has (amongt others) a field for species (text), clip-status (yes/no), coded wire tag status (yes/no), and 'count' (number). The count field is necessary to allow input of groups of fish en-masse, or individually, depending on the amount of accessory information obtained.

Obviously, some sets catch no fish and so no record is entered into the fish table for those sets.

When I design a query, I want to produce a table that sums up the count field for each set, and produces subtotals for each species (and for the 4 variations of the clip/tag status fields).

My efforts so far are only partially succesful in that I can produce the correct subtotals, but only for sets where something was caught. Sets with no corresponding fish_table record are ignored instead of treated as zeroes.

Is it necessary to manually enter a 'zero' count for each species of interest for each set that we do? (Massively time consuming) Or is there some other way to query the db that forces the query to equate no fish record with a zero value?

Any thoughts? I've searched the forum, and googled, but haven't come across anything I could recognise as analogous to my dilema.

View 8 Replies View Related

Concatenating Fields Ignoring Blanks

Jun 4, 2006

In a query, I'm using concatenation to join multiple address fields (organisation, building number, street address, etc) into one field. I'm also inserting line breaks to create a formatted address and then creating a form on the query so the formatted address appears in a text box and can be copied and pasted straight into my label-writer software to print address labels.

This is the concatenation code I'm using:

Expr1: [Organisation] & Chr(13) & Chr(10) & [Building Number] & Chr(13) & Chr(10) etc.

However, one problem with which I am now presented is where a field is blank. E.g. if one of my contacts is retired, then they don't have an organisation listed in the "Organisation" field. This means that a blank line is left between their name and the rest of the address.

When running a mailmerge there is the option of skipping blank fields so that a blank line is not inserted in such cases.

How can I achieve this within the above code?

Gary

View 6 Replies View Related

Create A New Table Ignoring Dupes

Jul 18, 2006

MS Access 2000

I have 2 tables “MDW” and “LeadList”
Each table contains the same type of data (Contact information)
Some duplicate records MAY be in both tables.. (I would like to ignore the dupes).
Each table has a unique ID field but are in no way related

I need to create a 3rd table “NewTable” WHERE…
MDW!FirstName is not = to LeadList!FirstName
And
MDW!LastName is not equal to LeadList!LName
And
…….. I need to look at 10 fields

My thought was to create a query with both tables. Create Joins (where both are equal) for all 10 fields and moving on from there. The fields may or may not have values. I don't think I could add records if only of the indexed fields are null... Can I?

Does anybody see me walking in front of a freight train? Or, any other ideas?

TIA
Detrie

View 1 Replies View Related

Summing Fields, Ignoring Certain Values

Jan 29, 2008

I have a number of fields that hold values (scores - either 0,1 or 2) that need to be summed but in some cases the value is 99 (which is recognised by our stats program as a N/A type of anwer- This occurs when a question is optional and the user hasnt answered it. I did not want to value to be null (since its not like the user didnt answer it because they missed out on it by accident but rather they could not) and it couldnt be 0 either since 0 actually means something different in the context of the questionnaire.Lets say I have Q1 which has a value of 0, Q2 has a value of 1, Q3 has a value of 99 and Q4 has a value of 2I want to get the total of Q1+Q2+Q3+Q4 for a particular entry but if the value of any or all of the questions are 99 I want access to ignore it and just sum the rest of the values i.e. the sum should read 0+1+2+(99)=3 not 102I want to be able to include this sum function in the expression builder if possible since I am using it for a report. Can someone please help?

View 3 Replies View Related

Ignoring Blank Fields (explained Better?!)

Jan 16, 2006

I have a Text box on a Form that copies data entered into other Text boxes on the same form.
I have used the formula =[Text2] &" "& [Combo26] etc in the main text box that I want all the information in.
Sometimes there may be the odd text box that does not have any data in it.
Is there anyway that I can put in code so that the blank text boxes are not copied into the main text box i.e. Only the populated text boxes are to be copied.
Thankyou for any assistance that you can provide.

View 1 Replies View Related

Yesterday Date Ignoring Weekends

Dec 9, 2013

I'm using the Date()-1 to populate a form with yesterday's date for easier data entry. However, on Mondays I always have to change the date to Friday's date because it is populating yesterday's date (which in this case is Sunday). Is there an access expression that calculate yesterday's date but ignores weekends? So that on Monday yesterday would mean Friday?

View 4 Replies View Related

Plus Or Minus

Mar 21, 2006

Hi,

I am setting up a query to display a records of products within certain sizes.

I want the width to be input, eg; "500" and i want all records - plus or minus 50 of this record to be displayed. I know i could use the "BETWEEN" "AND" command but i want the user to only enter 1 size if it is possible.

Any help greatly apreciated.

Thanks

Don

View 1 Replies View Related

Ignoring Null Values From Form In Query

Mar 21, 2006

I have a form with 4 different search fields used to query a table and limit results: Policy#, SSN, Credit_Amt, Debit_Amt. Any matching rows based on the search criteria are returned in a subform.

My problem is how to handle any fields where the user doesn't specify a search value.

In my query, I have the Criteria set to:
Field: Policy_No
Criteria: =[Forms]![form name]![Policy#]

Field: SSN
Criteria: =[Forms]![form name]![SSN]

and so on....

If I place my criteria on different OR lines, the query runs, but if a user specifies more than 1 criteria, I get all the data for one criteria(such as policy# matches) and all the data for the second criteria(such as all the records for a certain credit_amt, regardless of Policy #).

If I place my criteria on the same criteria line, effectively making it AND, I get no results because I assume the database is looking for any blank search field values.

So, how do I make the query an "AND" query, but actually get results by ignoring any NULL search fields? So if a user enters a Policy# and Credit_Amt, the results will be only matching rows by Policy# AND Credit_Amt, and doesn't look at SSN and Debit_Amt.

I've tried different iterations using IIF(Not IsNull(.... to no avail.

Thanks!

View 3 Replies View Related

Ignoring Leading Zeros In Join Query

Jul 9, 2007

Hi everyone,

I have 2 linked tables from 2 different databases, there is a common field in both: “CORP_NBR” I need this field in order to create a join, but the problem is that in one table this field stores leading zeros and in the other table it doesn’t. I can see in design view that this field is text type in both tables. I cannot change field types because I don’t own the objects.

Is there a way or a function that I can add in my join query to ignore leading zeros? :confused:

I appreciate your help

View 6 Replies View Related

Minus Figure

May 20, 2005

Hi
This is probaly really easy, I want to identify just minus figues in a query ie -5.00. I have tried iif([TotalPrice])<0,[TotalPrice]) this shows no result. Can any one advise. Thanks in advance.

View 1 Replies View Related

MINUS Operator

Nov 15, 2005

Hi guys!

It's unknown for me why Access hasn't got MINUS implemented and Unmatched Query Wizard doesn't help me much. So I'm wondered if anyone had to confront the following task:

Table1

Book Agent
----------
b1 a1
b2 a2
b3 a3

Table2

Book Agent
----------
b1 a1
b3 a3

The problem is I have to eliminate duplicates but I need to find unique row, which is Book and Agent. From my example it's row with (b2 a2). I tried using
Select * From Table1
Where (Book, Agent) Not In (Select Book, Agent From Table2)
didn't work
I also tried EXISTS
didn't work
Unmatched Wizard compares only one field, not two.

Any comments welcome, thank you

View 2 Replies View Related

Minus &lt;-&gt; Union

Jul 11, 2006

To fill a ddl list I could use a MINUS query. I found out that UNION and UNION ALL work, but MINUS doesn't.

Is there a way to make it work, or maybe an other way to solve this kind of problem?

View 1 Replies View Related

Get A Minus Number Where It Should Me A 0

Mar 15, 2005

Hi,
I've searched this forum and can't quite get what I need.
I have a subform on a form, in the footer of the subform I total an amount owing field. Then I get the value from the footer control to the main form. I know that the total should be 0 but on the main form I get a -0.0119. How can I get this to show 0.
Thanks

View 1 Replies View Related

Forms :: Split Form Ignoring Record Source?

Jan 15, 2014

Access 2013 on a Window 8.1 system.

I have a combo box based on a look-up table which I use to filter the records in the form. Seems after closing the form and reopening it, the filter remains.

I'm not sure if this is referred to filtering or restricting the records.

The value in the record source doesn't get changed but the records displayed don't reflect this. The records shown are the last filter I selected in the combo box.

The only work around I have found is I must explicitly set the record source in the on open of the form.

The was not occurring with access 2010. And I have made no changes what-so-ever.

View 5 Replies View Related







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