473,467 Members | 1,291 Online
Bytes | Software Development & Data Engineering Community
Create 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 2105
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.Connection, rstPays As adodb.Recordset
Set cnnTrip = Application.CurrentProject.Connection
Set rstPays = New adodb.Recordset
'open the recordset
rstPays.Open Source:="payments", ActiveConnection:=cnnTrip, _
CursorType:=adOpenForwardOnly, LockType:=adLockPessimistic
'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").Value = rstPays.Fields("paid").Value - strPayment
'assign current date
rstPays.Fields("updated").Value = 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,556 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
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...
1
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" -...
6
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
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...
0
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%...
1
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...
3
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...
3
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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...
0
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,...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.