Currently I have a table, and would like the calculate a field in the table by referencing values from another 3 tables.
i.e. tblData - Index1, Index2, Index3, Value
-
1 2 3
-
2 2 2
-
1 3 4
and tblIndex1 - Value Data
-
1 2.5
-
2 2
-
3 1.5
and tblIndex2 - Value Data
-
1 2.5
-
2 2
-
3 1.5
etc
so if tblData, field Index1 = 1, then take the Value field from tblIndex1 which is the same as tblData.Index1 and do the same for Index2 and Index 3 and then tblData.Value is a calculation based on those indexes.
i.e. Value = 2.5 * 2 * Index3.Value.
I want to perform this calculation for every ID in tblData.
I've written the following code: - Private Sub cmdUpdate_Click()
-
Dim rcdTesting As DAO.Recordset
-
Dim rcdReference As DAO.Recordset
-
Dim rcdReference2 As DAO.Recordset
-
Dim rcdReference3 As DAO.Recordset
-
Dim I As Variant
-
Dim Constant As Integer
-
Dim Constant2 As Integer
-
Dim Constant3 As Integer
-
-
-
Set rcdTesting = CurrentDb.OpenRecordset("tblTest2")
-
Set rcdReference = CurrentDb.OpenRecordset("tblReference")
-
Set rcdReference2 = CurrentDb.OpenRecordset("tblReference2")
-
Set rcdReference3 = CurrentDb.OpenRecordset("tblReference3")
-
-
With rcdTesting
-
For Each I In rcdTesting
-
If ![Outing] = rcdReference![Value] Then
-
Constant = rcdReference![Result]
-
End If
-
If ![Lap] = rcdReference2![Value] Then
-
Constant2 = rcdReference2![Result]
-
End If
-
If ![Time] = rcdReference3![Value] Then
-
Constant3 = rcdReference3![Result]
-
End If
-
![Value] = Constant * Constant2 * Constant3
-
Next I
-
End With
-
-
End Sub
But it says I am declaring the I, in the for each statement incorrectly.
Currently the code is written so it updates on button press, but ideally I would like the field up update automatically as each Index value is entered.
Any help would be greatly appreciated.
Thanks,
Zoe
1 2179 NeoPa 32,579
Recognized Expert Moderator MVP
Zoe, there are currently too many typos to read your problem without getting confused.
Please take the time to prepare a question that is legible if you would like our experts to take their time to try and help.
-Administrator.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: JLM |
last post by:
I have a table that has fieldA, fieldB, fieldC. I want
fieldC=fieldA-fieldB. simple enough. the next record I want to be able to
do the same on the new value of fieldC.
I can do this with SAP ABAP/4, but have never done this using Access.
I'm sure this can be done, but not sure how to go about it.
thanks in advance,
jlm
|
by: jlm |
last post by:
I have a form which feeds table (TblEmpLeave) of Employee Leave Time
(time taken off for Administrative, Annual, Sick, Compensation leave).
I have EmpID, LeaveDate, LeaveType, LeaveHours fields on this form.
Any employee can have multiple entries in the table (key fields are
EmpID and LeaveID) for multiple dates (John Doe can take 3 days annual
leave, then take 3 days sick leave in any given month.
I have a BeginningBalance of hours that...
|
by: Wayne Aprato |
last post by:
I've read most, if not all, of the posts on moving average and still
can't find a simple solution to my problem (if a simple solution
exists!) I have a table with 2 fields: Hours and Injuries. I have a
query based on this table which shows these 2 fields and calculates a
third field: Frequency Rate, based on a formula which uses the Hours
and Injuries fields.
Is there a simple way of A: using yet another calculated field in the
query...
|
by: Megan |
last post by:
quick summary: i'm having problems trying to group fields in a report
in order to calculate percentages. to calculate percentages, i'm
comparing the results from my grouped fields to the totals.
first, let me say that this is a really long post. i wasn't sure how
much information/ background to provide, so i thought more was better
than less. i tried to delineate certain areas so that it would be
easy to peruse my posting and find...
|
by: Tony Williams |
last post by:
I have a table with two fields, txtvalue (a number field) and txtmonth ( a
date/time field). I want to create a report that shows the difference in
value between the value in txtvalue in one value of txtmonth and the value
of txtvalue in another value of txtmonth and the percentage increase . For
example if I have the value 1000 in 30/03/03 and the value 1100 in 30/03/04
How do I calculate the difference as 100 and the increase as 10%. I...
| |
by: luscus |
last post by:
Thanks for all the responses on my first question. Unfortunately the
answers I was given were too complicated for my small brain , and
neophite condition to understand. So if you could talk down to me and
write in easier terms I would be very gratefull to all you access
wizards!
Here is my problem. I have a table with maybe 10 fields, It is used to
imput information taken over the phone to solve patient problems in our
Spanish...
|
by: swinster |
last post by:
Hi all,
I have not touched access for a very long time and am attempting to help my nephew with his Video Rental Database. This is a simple three-table relationship database comprising a Video Table, Customer Table and Rental Table.
We have a simple form whose source is set to the Rental Table. We want to calculate the fine on a late video using the number of days the video is late (from Rental Table) multiplied by the cost of the video...
|
by: zoeb |
last post by:
Hi.
I have a form which the user enters 2 years worth of data into (one record per year). The aim, is to populate the table this form is based on with 3 more years worth of data (i.e. creating 3 new records), based on a percentage increase on the previous year. This form is based directly on a table called tblBudgetShareProj.
So far I have the following code but I am COMPLETELY new to VB and I'm very aware of how incomplete it is. I have a...
|
by: Astley Le Jasper |
last post by:
Sorry for the numpty question ...
How do you find the reference name of an object?
So if i have this
bob = modulename.objectname()
how do i find that the name is 'bob'
|
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,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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...
| | |