DSum help

  • Follow


Being new to vba and Access, I think what I am trying to do is out of
my realm of understanding. I have two querries that query the same
table "QtyUsed". One query "QtyUsed6Mo" filters results by the date
field to records within the last 6 months. The other "QtyUsedYr"
filters within the last year. I want to create a DSum that will add
all the records in the query that have the same "NSN" and add the qty
"Used" to another table "DataTable.QtyUsed6Mo and DataTable.QtyUsedYr"
0
Reply Bobby 1/28/2008 10:03:05 PM

Bobby,
Usually it is not good practice to store these calculations in a table.
You can always use the query, both queries 6Mo and Yr to give the calculated 
values for a form's recordsource or for a report.
Using the query instead of a table, gives you the most up-to-date value for 
the values. It also avoids the problem that can happen when one of the dates 
is edited and this changes the value for QtyUsed. If the calculation was in 
a  table, you would need to change the value in the table every time one of 
the dates was edited - that is too much work - much easier to just use the 
query.
Note: there are some databases that do need to store a calculated value in a 
table, but this is not very frequent.

Jeanette Cunningham

<Bobby.Dannels@gmail.com> wrote in message 
news:a15eeec7-6ed7-4073-98aa-31452d247557@b2g2000hsg.googlegroups.com...
> Being new to vba and Access, I think what I am trying to do is out of
> my realm of understanding. I have two querries that query the same
> table "QtyUsed". One query "QtyUsed6Mo" filters results by the date
> field to records within the last 6 months. The other "QtyUsedYr"
> filters within the last year. I want to create a DSum that will add
> all the records in the query that have the same "NSN" and add the qty
> "Used" to another table "DataTable.QtyUsed6Mo and DataTable.QtyUsedYr" 


0
Reply Jeanette 1/28/2008 10:13:22 PM


Can I not write a code that will update the table every time the value
in the query changes? If not, how would I write the code that I need
to have the form pull straight from the query?
0
Reply Bobby 1/28/2008 10:47:11 PM

On Jan 28, 2:47=A0pm, Bobby.Dann...@gmail.com wrote:
> Can I not write a code that will update the table every time the value
> in the query changes? If not, how would I write the code that I need
> to have the form pull straight from the query?

More importantly how would I get the query to filter the table by the
nsn that is currently being displayed in the form?
0
Reply Bobby 1/28/2008 11:38:35 PM

Yes you could write code to do this. What happens if someone imports data 
into the table? It is not best practice to store the calculation.
To have the  form pull straight form the query - you would do a DLookup to 
the query and put the result in a label or textbox.

Jeanette Cunningham

<Bobby.Dannels@gmail.com> wrote in message 
news:a9969329-76ae-40a5-916a-7d12ff404389@v46g2000hsv.googlegroups.com...
> Can I not write a code that will update the table every time the value
> in the query changes? If not, how would I write the code that I need
> to have the form pull straight from the query? 


0
Reply Jeanette 1/29/2008 4:33:03 AM

In design view of the query, in the criteria row for nsn, type the correct 
syntax for the name of the nsn control on the form.
Forms!YourFormName!TheControlName  - assuming a form that is not a subform.
As long as the form is open, the query will be able to get the nsn value 
from the form.

Jeanette Cunningham

<Bobby.Dannels@gmail.com> wrote in message 
news:befe8479-892e-4472-b6ef-613e971ba070@l1g2000hsa.googlegroups.com...
On Jan 28, 2:47 pm, Bobby.Dann...@gmail.com wrote:
> Can I not write a code that will update the table every time the value
> in the query changes? If not, how would I write the code that I need
> to have the form pull straight from the query?

More importantly how would I get the query to filter the table by the
nsn that is currently being displayed in the form? 


0
Reply Jeanette 1/29/2008 4:39:25 AM

5 Replies
219 Views

(page loaded in 0.117 seconds)

Similiar Articles:
















7/16/2012 1:10:19 AM


Reply: