473,466 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Update one table with another table field value

4 New Member
Hi All,

Am trying to update one table with another tables value where both tables have a common relationship.
my code is a below.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "update customer set customer.paid" = totalprojsumpaid.AMOUNT where "customer.ACCNO = totalprojsumpaid = ACCNO"
  2.  
Note the two fields calculated fields.

Thanks,
Njoroge Joseph
Nov 11 '15 #1
9 3797
strive4peace
39 Recognized Expert New Member
perhaps this?

Expand|Select|Wrap|Line Numbers
  1. dim sSQL as string
  2. ssql = "UPDATE Customer C INNER JOIN totalprojsumpaid TP " _
  3. & " ON C.ACCNO = TP.ACCNO " _
  4. & " SET C.Paid = TP.Amount"
  5.  
  6. currentdb.execute sSQL

This will do all records since there is no criteria for a specific account
Nov 11 '15 #2
jgitaunjoroge
4 New Member
Strive4peace,

Please note when i run the code it returns Two few parameters. Expected 1

Customer.paid is the main table being update by totalprojsumpaid.amount
the criteria is Customer.accno=txtaccno must be same with totalprojsumpaid.accno as it is in relationship. txtaccno is a text field recording accno for both tables.
Nov 11 '15 #3
strive4peace
39 Recognized Expert New Member
your error message suggests that something is not filled out. What is the SQL for totalprojsumpaid ? (am assuming it must be a query).

Perhaps there is a better way to update the paid field in your customers table.
Nov 11 '15 #4
zmbd
5,501 Recognized Expert Moderator Expert
jgitaunjoroge,

What we should understand first is why you are doing this in the first place. A normalized database most likely would not need such an update between tables.
Nov 12 '15 #5
strive4peace
39 Recognized Expert New Member
sorry to disagree, but not necessarily. If methods are in place that can be run anytime, storing some calculated fields in favor of better performance is ok, in my opinion. I know not everyone agrees with this but I have seen many databases that took a long time to calculate -- not because they weren't designed properly, but because there was so much data.
Nov 12 '15 #6
zmbd
5,501 Recognized Expert Moderator Expert
S4P:
Certainly there are times when such things are needed - agreed; however, I am not sure why you would disagree with my last post in it's entirety, in as much as it is an inquiry regarding the basis for OP's goal - in which I noted that most likely such things are not needed within a properly normalized database - not that there is never a need... to whit: Is it for an audit trail, a one time discounted price, or as you've noted - a prefetch/calc for efficiency on a large dataset (I've done this myself in temp tables upon occasion :) )

IMHO, once we have a better understanding of what OP is trying to accomplish we might be able to point him towards a solution to the problem or maybe a better method of handling the data. Indeed, we may need a bit more detail too before the picture clears up for us. :)
Nov 12 '15 #7
strive4peace
39 Recognized Expert New Member
sorry, it just seemed a little rough to me .... I agree that a better understanding would help.
Nov 12 '15 #8
zmbd
5,501 Recognized Expert Moderator Expert
strive4peace, if occasionally something seems/appears to be harsh, please keep in mind that many of my shorter posts are along the line of a "text-message" - devoid of body language - short - concise. I work in a lab and all too often these post are made in the 5 minute break between tests and my normal data-entry and DBA tasks; thus, I need to pack a lot of information in a very short time frame....

bright side... I've learned to touch type at a rate I would never have thought possible :)
Nov 12 '15 #9
strive4peace
39 Recognized Expert New Member
Thanks. I have read some of your posts, zmbd, and most are very good (must be that scientist way of thinking). Oftentimes, alleviating frustration with comforting words gives others a way to see the answer for themselves. Access is hard to learn. I applaud those who try.
Nov 12 '15 #10

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

Similar topics

1
by: Bryan | last post by:
Hi, I have two tables. I want to update two columns in my first table, and with two values and held in my #temp table but based on a RUN_DATE from my first table. Can anyone point me in...
2
by: Mike | last post by:
I'm sure this has been covered before in the newsgroup but have had no luck locating it. I have two tables: InstMonitors & MonModDesc Structure of MonModDesc: Model, Description Structure...
2
by: Bob | last post by:
How do I extract the value of a table field and save it to a variable of similar data type in VBA ? Thank you in advance, Bob.
1
by: MLH | last post by:
Can someone tell me what I'm doing wrong in this query? UPDATE tblEventsSituationsIncidents SET tblEventsSituationsIncidents.ES01 = +1; I'm trying to update the value in table field and am...
3
by: Chris Morton | last post by:
Not sure if this is the right location for this question. I Saw several previous FP questions in this Group and did not see one for VFP.... If this is the wrong group, please direct me...
5
by: devx777 | last post by:
Hello, I am trying to find some information or an example on how to build a dynamic query in DB2 that would allow me to join a table which its name is stored as a field value on another table....
2
by: David - Australia | last post by:
G'day from Australia, I'm hoping some bright spark may be able to help me with this one. I'm sure that it can be done, I've just hit a wall with it. So I'm opening it up. I'm storing student...
10
by: karlspharm | last post by:
I'm using Access to track property assigned to personnel. The problem that I've encountered has to do with marking the property as "Surplus" when it is no longer used. I have a surplus form...
2
by: timleonard | last post by:
How do you reference the Table:Field to use in a file path? I have been trying the code below I would like to reference a Tablel:Field to use in the path instead of hard coding the file name,...
6
by: neelsfer | last post by:
I do race timing. I capture race numbers in a subform, a sequential lapnumber is created, and the racenumber and finishtime are appended in realtime to a specific lap number fields in another...
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
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...
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
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...
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?
0
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 ...

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.