2 Replies - 1236 Views - Last Post: 26 August 2012 - 08:20 PM Rate Topic: -----

#1 ddeaton1987  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-August 12

Simple question with Microsoft Access

Posted 26 August 2012 - 11:07 AM

I want to be able to add / subtract several fields in Access.. I'm brand new to VB as well (clearly as this seems very simple).
Can someone point me in the right direction with example fields named [Example 1] and [Example 2] on how to add or subtract these.
Both fields are Doubles if that matters at all and eventually I will be doing more than adding them... But I need a relevant example to start!!
Thanks for the help and I'm sorry if this can be found elsewhere but a quick search didn't give me exactly what I'm looking for (probably because I do not know how to articulate the search to return the results I'm seeking)

Is This A Good Question/Topic? 0
  • +

Replies To: Simple question with Microsoft Access

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4424
  • View blog
  • Posts: 12,293
  • Joined: 18-April 07

Re: Simple question with Microsoft Access

Posted 26 August 2012 - 07:39 PM

I am not sure how exactly you are wanting to sum these and for what. Are you wanting to sum them in VB? Do you want to create a query where you update a field with the sum of the other two fields in a given record/row?

For instance if you have a table that contains columns [Example1] and [Example2] and you want to update all rows' column [ExampleSum] then you can do it with a query like so...

update tablename set ExampleSum = Example1 + Example2



This will update all rows and set each rows' [ExampleSum] column to the total of [Example1] + [Example2] of that row.

If you are wanting to pull the values into VB and add them there, then you query the rows you want, loop through them, fetch the values for the two columns, add them and then do something with the sum.

Hope that makes sense to you. :)
Was This Post Helpful? 0
  • +
  • -

#3 ddeaton1987  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-August 12

Re: Simple question with Microsoft Access

Posted 26 August 2012 - 08:20 PM

I'll be adding alot of times together, then rounding them to a decimal (making it not ideal to use the expression builder). And you hit it dead on, i do want to output these values and update a 3rd not mentioned (in my previous post) field.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1