Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Function Not Working
Musoke Herbert 
   
2 years ago
Hello members What could be wrong with this Function am trying to Build?

Public Function TotalPoints(StudentID As String, Class As String, Term As String, SchoolYear As Number) As Long

    ' Returns the total Number of points  for a given Student in A class in a given term in a year

    TotalPoints = DSum("GP", "ALevelreportsQ", "StudentID = '" & StudentID & "'  AND Class = '" & [Class] & "'  AND Term ='" & [Term] & "' AND SchoolYear =" & [SchoolYear] & "")
End Function
Kevin Robertson  @Reply  
           
2 years ago
StudentID is usually a Long. In which case the single quotes won't be needed (check your data type).
Number is invalid - should be either an Integer or a Long.
Musoke Herbert OP  @Reply  
   
2 years ago

Musoke Herbert OP  @Reply  
   
2 years ago
Well, Kevin, this is how it looks, StudentID has a default Value and its a String like you , See, i have actually made number integer but not working still
Sami Shamma  @Reply  
             
2 years ago
I think your problem is with the Duble Quotes
Put The:

S = "StudentID = '" & StudentID & "'  AND Class = '" & [Class] & "'  AND Term ='" & [Term] & "' AND SchoolYear =" & [SchoolYear] & ""

In a variable and Msgbox S

I think you will find the problem.
Kevin Robertson  @Reply  
           
2 years ago
Can you give us more details?

When you say it doesn't work, what EXACTLY happens?
Is 'GP' a numeric data type?
How are you calling the function?
Do you receive any error messages?

I set up a basic table to test your function and it worked for me.
Richard Rost  @Reply  
           
2 years ago
Yeah this is one of those situations where we really need to see some sample data
Musoke Herbert OP  @Reply  
   
2 years ago

Musoke Herbert OP  @Reply  
   
2 years ago
I have put it underthis , Not working to
Musoke Herbert OP  @Reply  
   
2 years ago

Musoke Herbert OP  @Reply  
   
2 years ago

Sami Shamma  @Reply  
             
2 years ago
How are you calling the Function?
Musoke Herbert OP  @Reply  
   
2 years ago

Musoke Herbert OP  @Reply  
   
2 years ago

Musoke Herbert OP  @Reply  
   
2 years ago
Am calling the Function TotalPoints in a Querry!
Richard Rost  @Reply  
           
2 years ago
You didn't show half the fields we need to see. Where's GP? StudentID?
Richard Rost  @Reply  
           
2 years ago
None of this is helpful if we can't see it all together. Just looking at a column of numbers does nothing.
Kevin Robertson  @Reply  
           
2 years ago
Please let us know how you are calling this function.
You have declared 4 arguments for the function so they need to be stated in your function call.

This is an example in VBA:
    txtPoints = TotalPoints("555", "Access", "3", 2024)

txtPoints is the name of a Text Box on my Form.
Musoke Herbert OP  @Reply  
   
2 years ago

Musoke Herbert OP  @Reply  
   
2 years ago

Musoke Herbert OP  @Reply  
   
2 years ago
That is How am Doing it
Kevin Robertson  @Reply  
           
2 years ago
You are sending GP to the function.
You should be sending: StudentID, Class, Term, SchoolYear
These are the FOUR arguments declared in the function.

Please watch this video: Create Function

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/7/2026 2:01:35 PM. PLT: 1s