473,722 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DSum function issue with conditions / criteria expressions

46 New Member
Hi community experts,

I am having an isue with Dsum function that is used to count the total number for a particular field (intake) at the textbox afterupdate event with condition/ criteria (subject). Below is the scenario in details.

What I need to do is summing the intake corresponding to what is selected from the dropdown combo box. For instance if the user choose maths in the combo box, the total no of intake should be displayed in the subject textbox as 150.

May I knw hw can that be achieved and whether I am in the correct direction? I have provided the necessary details that is required for this scenario. Tks for advice, code snippets.

Form controlSource = Registration Table

Expand|Select|Wrap|Line Numbers
  1. Registration Table design view
  2.  
  3. SerialCode        autonumber        primary key
  4. subject             text                            
  5. intake               number
  6.  
  7. Registration Table view
  8.  
  9. SerialCode         Subject             Intake
  10. 1                       maths               100                        
  11. 2                       science             100        
  12. 3                       maths                 50      
  13. 4                       science               50         
  14. 5                       english              100              
  15.  
  16. Form design view
  17.  
  18. Subject            unbounded combo box
  19. Subject            unbounded textbox
  20. Intake              unbounded textbox
Code

Expand|Select|Wrap|Line Numbers
  1. Private Sub Subject_AfterUpdate(Cancel As Integer)
  2. Dim sum As Variant
  3. sum = DSum("Intake", "Registration", "subject = '" & Me.ComboSubject.Column(0) & "'")
  4. Me.Requery
  5.  
  6. End Sub
Feb 6 '07 #1
3 2987
NeoPa
32,569 Recognized Expert Moderator MVP
Your code doesn't seem to know what the control is named :
Private Sub Subject_AfterUpdate but later on :
Me.ComboSubject.Column(0)
Also, after setting up the variable Sum it doesn't seem to use it anywhere.
Feb 7 '07 #2
technocraze
46 New Member
tks for the reply. issue has been solved


Your code doesn't seem to know what the control is named :
Private Sub Subject_AfterUpdate but later on :
Me.ComboSubject.Column(0)
Also, after setting up the variable Sum it doesn't seem to use it anywhere.
Feb 7 '07 #3
NeoPa
32,569 Recognized Expert Moderator MVP
You're welcome, and thanks for letting us know.
Feb 7 '07 #4

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

Similar topics

0
3351
by: Rolan | last post by:
I'm using Access 97 and need some assistance in sorting out a proper DSum expression, or maybe even DCount might be an alternative. I have tried numerous combinations, but with no apparent success. The DSum function relates to a subform (sfrmCost) with a text box (RefCost) which is intended to be the container for a total from a query (qryItems). The query has three number columns from the table (tblItems) of which I have an expression...
1
4800
by: Dalan | last post by:
I have tried both methods of using DSum and creating a Function to address summing some number columns, but to no avail. Since this has been a popular topic over the years, I'm sure I'll receive some guidance. This is related to Access 97 and involves my redoing a miscellaneous purchase and sales form. A main form (frmMain) is used that contains summary information of the item. I incorporated two continuous subforms (sfrmPurchases) and...
2
11588
by: Dalan | last post by:
I seemed to be having problems with structuring the use of NZ with a DSum expression. Having tried numerous variations of the expression without success, I'm asking for assistance. First some background (Access 97) - the DSum expressions are being used in grand total text boxes on the footer of a subform. And when viewing the subform in the linked main form the two grand total boxes display #Error if no entry had been made. Those with...
0
1589
by: Dalan | last post by:
I have a select query with a few DSum expressions, but when I add a between and ending date parameter to Date Sold, the results show #Error in two (discount and net sales) of the four gross total columns. This is a sales activity query that has GT Units Sold, GT Gross Sales, GT Discount, and GT Net Sales columns. Without using the date parameter, all grand totals are computed correctly. Not that it should be an issue, I am using NZ as part...
3
3766
by: Mark Reed | last post by:
All, I have never used this function before and am not sure it what I need. Just to clarify, I have a report based on a query which has amoungst other field, wk, parea & packs_req. What I am trying to do is create a subreport for the main report which gives a generalised breakdown of the main report. For the gender of 'Ladies', there may be several parea's so I want to sum the packs_req for ladies only. (Gender is not a field I can use,...
3
2957
by: beppe005 | last post by:
I would like to calculate a total for all the field with the same in a query. I don't know how to set the "criteria" for this dsum function, it should be something like = but it doesn't make sense. The query is something like: +-- --- ---- ---- --- ---+ +--1-----Alpha-------a1----------------1------------4------------------+ +--1-----Alpha-------a2----------------3------------4------------------+
3
4704
patjones
by: patjones | last post by:
Good morning all: In what seems like an ongoing saga to make the DSum function do what I need it to, I am now having trouble with a user-defined function in my VBA module. Here's the offending line of code: Me!txtLostDaysNoPaySeasonal = DSum("getNumberOfWeekdays(!, !)", "qryTest", "! = 'BK21312'") In this, getNumberOfWeekdays is a function that I define elsewhere in the module, as such: Function getNumberOfWeekdays(dteStartDate...
2
3397
jmoudy77
by: jmoudy77 | last post by:
Hi, I'm trying to use a variable "FirstSemi" as the second criteria in a DSum function. The DSum function is used in the same Form_Load function that the variable was declared. I keep getting an error referencing the variable in the DSum function when the form loads. Any ideas? And > FirstSemi") -Josh
3
2074
by: majapa | last post by:
To start, here is my DSum expression: Develop: Nz(DSum(". & "] + . & "]","CSO","='Ability to Develop'")*-1,0) I actually have 4 of these, each one with a different option for . For more context, the . part is drawing from a separate reference table which cycles through plugging in the name for each DB_ and Ben_ field in the CSO table. What I want to do is add another layer of criteria, the field which exists in the same CSO table. I'd...
0
8739
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9238
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9157
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.