# Web Development

## General discussion

Locked

By ·
I have an Access Table that I can query by beginning and ending date using SQL statements but I want to add a column of the results and perform a calculation on it eg. get the total of one column and find what percentage that total is of the total of another column (or something like that, I'll have to ask the engineers what exactly they want) but they want to perform calcs on the totals of those columns.

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)
| Thread display: Collapse - | Expand +

Collapse -

Step one, to get your total in one column, sum it. It will sum it by the date, so create a second query based on the first one, but don't use the date range, just the nember and sum the number - you now have a total for the column.

To perform more math on it:
Use the builder to select the field or qry you want and the imple math symbols to do the math for you. A lot can be done with parenthesis in one qry.

Hope this helps.

Collapse -

The question was auto-closed by TechRepublic

Collapse -

If you have a form that provides viewing of this table, you could use the DSum function to calculate the totals you need.

For example:
Dim lngTotal1 as Long
Dim lngTotal2 as Long
Dim dblPercent as Double

lngTotal1 = DSum("[Col1]","[TableName]","[Date] = #" & me.txtSelectedDate & "#")

lngTotal2 = DSum("[Col2]","[TableName]","[Date] = #" & me.txtSelectedDate & "#")

dblPercent = 100 * lngTotal1/lngTotal2

The third part of the DSum calculation is the where clause. In this exampleI've assumed that the column called [Date] must equal the date in the current form (me) object called txtSelectedDate.

Collapse -

The question was auto-closed by TechRepublic

Collapse -

This question was auto closed due to inactivity

5 total posts (Page 1 of 1)

## Related Discussions

• 7

helen15 //

• 10

#### Responsive Designs are the future of Web Development

gowebdardy //

• 1

manish0u //

• 0