Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 15th, 2007, 12:26 PM
Authorized User
 
Join Date: Sep 2006
Location: , IN, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Form's calculated field not working properly

Greetings,

I have a form with 4 values that I want to sum for each detail record displayed. Something like this.

val1 val2 val3 val4 sum of these 4 values
val1 val2 val3 val4 sum of THESE 4 values
.
.

When I sum these values. I get a result BUT it appears on all records in the form... not just for the individual detail. Like this:

2 2 2 2 8
2 1 1 1 8

If this explains it enough, how can I make it so it works like this?

2 2 2 2 8
2 1 1 1 5
etc.
thank you...

Paul
__________________
Paul
Reply With Quote
  #2 (permalink)  
Old February 15th, 2007, 03:47 PM
Friend of Wrox
 
Join Date: Jan 2007
Location: , , .
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to scandalous Send a message via MSN to scandalous
Default

Thats Interesting.

Is it a continuos form?

Whats your query look like?

Reply With Quote
  #3 (permalink)  
Old February 15th, 2007, 03:57 PM
Authorized User
 
Join Date: Sep 2006
Location: , IN, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes... It is a continuous form. My query is a stored procedure...

In the form I have an unbound field... not part of the stored procedure, that has a sum statement:
=Sum([ArcDistanceA]+[ArcDistanceB]+[ArcDistanceC]+[ArcDistanceD]).
A clue is that when I only sum ArcDistanceA it sums up all ArcDistanceA values in all 4 records, not just the one record.
I must be missing something.

Hope that helped explain it further...thank you..

Paul
Reply With Quote
  #4 (permalink)  
Old February 16th, 2007, 08:28 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

This won't work in a continuous form. Try doing your calculations in the query itself by adding a column and summing the four columns in the query, and then display the summed column in your form.


mmcdonal
Reply With Quote
  #5 (permalink)  
Old February 16th, 2007, 08:44 AM
Authorized User
 
Join Date: Sep 2006
Location: , IN, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sir,

A wrinkle is this... you knew there was a wrinkle...

The 4 values will need to be updatable and the sum field will need to reflect it. In trying a stored procedure before, I could not update the 4 values. Did I mention I was fairly new to Access 2003?

thanks for your thoughts and help on this.


Paul
Reply With Quote
  #6 (permalink)  
Old February 16th, 2007, 08:48 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Does it have to be a continous form?


mmcdonal
Reply With Quote
  #7 (permalink)  
Old February 16th, 2007, 09:30 AM
Authorized User
 
Join Date: Sep 2006
Location: , IN, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Tried it. It says that the field (value 1) can't be edited because it is part of an expression. Perhaps there is something I do not have set that would be intuitive to someone like you. By the way, doing the sum field your way... i.e. is a SP makes the sum calculation work for each line. That's good. I just can't update the 4 values. probably something simple...

thanks...

Paul
Reply With Quote
  #8 (permalink)  
Old February 16th, 2007, 02:06 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Put the calculation on the data entry form, not in an SP on the server. Put the calc on the Before Insert and Before Update event of the data entry form.

Me.CalcdField = Me.Field1 + Me.Field2 + Me.Field3 + Me.Field4

That sort of thing.


mmcdonal
Reply With Quote
  #9 (permalink)  
Old February 16th, 2007, 02:09 PM
Authorized User
 
Join Date: Sep 2006
Location: , IN, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK... will do.

Thank you...

Paul
Reply With Quote
  #10 (permalink)  
Old February 16th, 2007, 03:59 PM
Authorized User
 
Join Date: Sep 2006
Location: , IN, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I must be missing something. It sums...but it sums for the current record... THEN applies that sum value to every record. I tried it continuout, single, and datasheet form.

Hmmm.

Paul
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ch 8 code is not working properly Dev_gh78 C# 1 August 4th, 2006 12:16 AM
Form's Unbound field question ebburks Access 4 June 6th, 2006 07:37 AM
How to create a Calculated Field fdtoo SQL Server 2000 0 April 11th, 2006 08:34 PM
PreparedStatement not working properly wslyhbb Java Databases 3 September 9th, 2003 01:08 PM



All times are GMT -4. The time now is 04:40 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.