473,394 Members | 1,752 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,394 software developers and data experts.

DSum function issue with conditions / criteria expressions

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 2965
NeoPa
32,556 Expert Mod 16PB
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
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,556 Expert Mod 16PB
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
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....
1
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...
2
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...
0
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...
3
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...
3
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...
3
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...
2
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...
3
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,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.