473,804 Members | 3,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculate amount student owes after payment made

1 New Member
Here is what I have for the code keep getting error on



Expand|Select|Wrap|Line Numbers
  1. 'declare variables and assign address to object variables
  2.     Dim strId As String, strPayment As String, curPayment As Currency
  3.     Dim cnnTrip As adodb.Connection, rstPays As adodb.Recordset
  4.     Set cnnTrip = Application.CurrentProject.Connection
  5.     Set rstPays = New adodb.Recordset
  6.     'open the recordset
  7.     rstPays.Open Source:="payments", ActiveConnection:=cnnTrip, _
  8.         CursorType:=adOpenForwardOnly, LockType:=adLockPessimistic
  9.     'enter student ID and amount paid, then convert amount paid to a number
  10.     strId = InputBox(prompt:="Enter ID:", title:="Student ID")
  11.     strPayment = InputBox(prompt:="Enter payment:", title:="Payment", Default:=0)
  12.     curPayment = Val(strPayment)
  13.     'search for ID in ID field, then update the record's Paid and Updated fields
  14.     rstPays.Find criteria:="id = '" & strId & "'"
  15.     'calculate total amount paid
  16.  rstPays.Fields("paid").Value = rstPays.Fields("paid").Value - strPayment 
  17.     'assign current date
  18.     rstPays.Fields("updated").Value = Date
  19.     'save changes to record
  20.     rstPays.Update
  21.     'close the recordset
  22.     rstPays.Close
  23.     Set rstPays = Nothing   'disassociate object variable from object
May 25 '07 #1
2 2127
JConsulting
603 Recognized Expert Contributor
Here is what I have for the code keep getting error on



'declare variables and assign address to object variables
Dim strId As String, strPayment As String, curPayment As Currency
Dim cnnTrip As adodb.Connectio n, rstPays As adodb.Recordset
Set cnnTrip = Application.Cur rentProject.Con nection
Set rstPays = New adodb.Recordset
'open the recordset
rstPays.Open Source:="paymen ts", ActiveConnectio n:=cnnTrip, _
CursorType:=adO penForwardOnly, LockType:=adLoc kPessimistic
'enter student ID and amount paid, then convert amount paid to a number
strId = InputBox(prompt :="Enter ID:", title:="Student ID")
strPayment = InputBox(prompt :="Enter payment:", title:="Payment ", Default:=0)
curPayment = Val(strPayment)
'search for ID in ID field, then update the record's Paid and Updated fields
rstPays.Find criteria:="id = '" & strId & "'"
'calculate total amount paid
rstPays.Fields( "paid").Val ue = rstPays.Fields( "paid").Val ue - strPayment
'assign current date
rstPays.Fields( "updated").Valu e = Date
'save changes to record
rstPays.Update
'close the recordset
rstPays.Close
Set rstPays = Nothing 'disassociate object variable from object

where is it failing?
May 26 '07 #2
NeoPa
32,579 Recognized Expert Moderator MVP
This is not an acceptable question Martin. We are not a code debugging service!
We can help you by answering specific questions, or we can work with you a little to help you resolve your problems. We do not do the work for you, especially when you give no indication as to what (if anything) you've tried and had trouble with.

If you would like to explain what you're trying to do and where, in the code, your efforts are failing (Error Message etc) then we can consider providing you with some help.

MODERATOR.
May 26 '07 #3

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

Similar topics

53
5753
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is difficult to know what is going on. One of these Order Forms you can see here... http://www.cardman.co.uk/orderform.php3
1
1394
by: oneillb | last post by:
I have a table I use to enter student data and would like my users to see a student's scholarship amount based on the data they enter into the following fields: - "First Year" or "Transfer" - "part-time" or "full-time" - high school GPA on a four point scale (ex. 3.52) - (ex 1160) - "resident" or "non-resident"
6
7478
by: Programador | last post by:
I'm getting this error when running this program: Cannot calculate rate using the arguments provided Module Module1 Sub Main() Rate(360, -694.44444444444446, 244274.69178082192) End Sub
7
43951
by: carterweb | last post by:
This is how I do it now. 1. Determine the dimensions of the rectangle. 2. Set a my font size to a fixed maximum size. 3. Apply the font my string and measure the string using the graphics object. 4. If string size is less than the size of the rectangle, we are done.
0
1537
by: rabraham | last post by:
I have a commission report I’m working on and it is causing to lose hair fast. I need help customizing this commission report. The current report has a couple conditions: Condition 1: Pay 2% commission of the payment amount if purchased in 2006 Condition 2: Pay 5% commission of the payment amount if purchased in 2007 The new report needs to calculate commission base on the type of item purchased, and the previous conditions.
1
2704
by: myemail.an | last post by:
Hi all, I am a novice to Access, and was wondering if I could get some help on a problem I can't solve. I have a database with customer payments, structured like this: customer code type of payment date of payment payment amount
3
2027
by: GODSPEEDELECTRONICS | last post by:
My database is simple. It has a table that tracks customers, with they're name, address, etc. I have a price list table that contains "iteminstall" , "price", and "qty" and I have a payment table that trackes date, and payment amount. I have a subform, with the field (textbox) "price." I have it auto populate when I type in something under (combobox) "iteminstall". This is a recent addition. I used to have to type it manually. In...
3
8519
by: supperham | last post by:
hi: can sone one tell me how to use fedex web service in php to calculate shipping fee? i already have fedex account and 4 keys used to test application Test Password:8pVQ6p5cHyQVuJJvrfosaBKqG Developer Test Key: vfNOPSmeA69gJFdf Test Account: 510087682 Test Meter: 1239156
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
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
10330
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...
0
10076
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9144
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...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3816
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
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.