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
2 2105
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?
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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"
-...
|
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
|
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...
|
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%...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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: 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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |