473,327 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Update field in table b from form a

I'm new to Access and VBA. (I've been working with Pick/Universe forever.)
I'm about going nuts trying to figure out something that should be (and most
likely is) very simple.

I have a form that reads and writes data from/to a table (call it
mainTable). It also reads data from a 2nd table (call it secondTable). What
I can't figure out how to do is update an item in secondTable from a
calculation in the mainTableForm. Specifically, I would like to take a value
from secondTable, subtract a value from mainTable and write the new value
back on the same field in secondTable.

Suggestions?

Bob

Sep 30 '07 #1
1 1915
Robert Martin wrote:
I'm new to Access and VBA. (I've been working with Pick/Universe
forever.) I'm about going nuts trying to figure out something that
should be (and most likely is) very simple.

I have a form that reads and writes data from/to a table (call it
mainTable). It also reads data from a 2nd table (call it
secondTable). What I can't figure out how to do is update an item in
secondTable from a calculation in the mainTableForm. Specifically, I
would like to take a value from secondTable, subtract a value from
mainTable and write the new value back on the same field in
secondTable.
The reason you are not finding obvious ways to do this is that in a properly
designed database the results of calculations are rarely stored in tables. The
calculation required to get the result is simply performed any time the value is
needed. That being said, there are a number of ways to accomplish this. The
simplest might be to use an update query.

UPDATE secondTable
Set SomeField = SomeField - Forms!mainTableForm!ControlName
WHERE (I assume you need to have some criteria here)

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Sep 30 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sue Adams | last post by:
I actually have two issues/questions: I have an autonumber field in an access db table that I grab and later use to update a record in another table withing the same db. The code I use to get...
4
by: news.btinternet.com | last post by:
I have a very simple database. I have information in a form that I would like to write to a table using some code. The table is called tblTest. The field I would like to write to is called Date....
4
by: N. Graves | last post by:
Hello... thank you for your time. I have a form that has a List box of equipotent records and a sub form that will show the data of the equipment select from the list box. Is it possible to...
15
by: Darren | last post by:
Help, i want to run an update query from a form.. and was wonderin.. Can the update query run if i want to update a value manually inputted from a form (e.g. !!) to a table...
2
by: Brett | last post by:
My database has 2 tables: Table1 & Table2. If a field is not null on a record in table2, then the not null fields in table1 that correspond to the records in table1 needs to be updated to match the...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
2
by: MirzaSila | last post by:
I have a form whitch record source is one of the tables I have in my database.I have various text fields on that form whitch control sources are table fields.When I'm inputing text into these text...
9
bhcob1
by: bhcob1 | last post by:
Hey guys, 'Update or CancelUpdate without AddNew or Edit' On my database i keep occasionly get this error when i try and edit a field, it is not everytime. It will be working fine and then this...
6
by: KevinPreston | last post by:
Hello everyone, this is my first post so apologies if i dont get it right first time, i am a self taught Access user, i am stuck on something i am trying to do, briefly i have 2 tables, one for...
6
by: wellsfargouser | last post by:
Hey everyone, this is driving me crazy. I have a table which lists all the files users have on the server. This table is called risklist. It lists the pathname and size. The goal is to make a form...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.