473,324 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Programatically setting the controlsource property of a summary field in a report

20
Hi all

I am dynamically creating a report in Access using a dynamic query. I use a record set to get the field names of a resulting query to set the controlsource property fields of the report fields and it works fine untill I wand to do the same for summary fields which are field4 and field5. These are displaying error in the report fields themeselves and not when I run the code any suggestions

Expand|Select|Wrap|Line Numbers
  1. If Not rs.EOF Then
  2.  
  3.            Field1.ControlSource = rs.Fields(2).Name
  4.            Status.ControlSource = rs.Fields(1).Name
  5.            Field2.ControlSource = rs.Fields(3).Name
  6.            Field3.ControlSource = "=([" & rs.Fields(3).Name & "]-[" & rs.Fields(2).Name & "])/[" & rs.Fields(2).Name & "]"
  7.            Field4.ControlSource = "=Sum([" & rs.Fields(2).Name & "])"
  8.            Field5.ControlSource = "=Sum([" & rs.Fields(3).Name & "])"
  9.  
  10.  
Aug 26 '10 #1
1 3172
MMcCarthy
14,534 Expert Mod 8TB
you can't do this
Expand|Select|Wrap|Line Numbers
  1. Field4.ControlSource = "=Sum([" & rs.Fields(2).Name & "])" 
  2.  
because the recordset can only see one record at a time.

You need to create a second recordset which sums those two fields.

Mary
Aug 28 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Gil | last post by:
Hello, I use VB.NET and have a series of linkbuttons that are inside individual <td>s. Like this: <td background="image.gif"><asp:linkbutton id="myID" runat="server"/></td> I would like...
3
by: Shelli Carol | last post by:
Good day, I have: 1) A table with numbered fields (1, 2, 3, etc.) 2) A form text box, whose ControlSource property contains an expression. This expression returns a number. If I just...
3
by: Osmosis | last post by:
I have a simple class like this Structure Eventitem Public logdate As DateTime Public recurring As Byte Public Description As String End Structure
3
by: Benny Raymond | last post by:
I'm currently working on giving my plugins space in my settings.xml file, actually, that's now working - however I would like to display each of the plugin's "setting" property summaries in the...
2
by: Vinayaka B L | last post by:
Hi all, 'm using ADODB.Command object for interactig with database in my application. In the code i'm calling "Execute" method to insert a new row into the database. After writing data into the...
2
Ali Rizwan
by: Ali Rizwan | last post by:
Hi all, I m usnig this command to set datasource property to datareport. DR.DataSource = "DE" But it is not working. Note: I dont't want to set this property from data report i want to set it...
4
by: drsvvr | last post by:
Hi everyone!, Please help me to do the setting page layout in data report. i dont think the default setting in data report is portrait, my project is need a landscape report, but i dont know how...
0
by: =?Utf-8?B?Q2hyaXN0aWFuIEJhaG5zZW4=?= | last post by:
Is it possible to bind a data access page textbox controlsource property at run time? I've tried using the BeforeInitialBind event to set the controlsource for textboxes, using syntax like ...
14
by: OldBirdman | last post by:
I have a textbox on a continuous form that I want to display a calculated value. I have set the ControlSource Property = & "~" & . I would like to have my user be able to correct this value, and...
2
by: Nick AU | last post by:
Hello, I am using MS Access 2003 and trying to set a textbox's ControlSource in VBA code. this following works fine Task.ControlSource = "." However, if i try to set the control source...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.