473,378 Members | 1,110 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,378 software developers and data experts.

Table updates as form inputs into another table.

16
I have 2 tables, one table is for the form to input records; and the other table is for keeping balances. How can I get my Balances table to update as new entries (+ or -) is entered in the input table? Any assistance is greatly appreciated!!!! =D
Oct 5 '10 #1

✓ answered by nico5038

I've started with changing your table structure. (Check the database relations!)
A tblAgent has been added to record the UpgradeQuantity.

The table tblBalance has an additional date and the NormalBalance has been dropped as "Starting balance as of 1 January" can be recorded on that date as a DateUpgrade qty while dropping the older dates.

Opening the form triggers the warning and a Yes will add the rows with the upgrade qty.

Finally the Balance on the form is made visible after selecting the Agent.

To finalize this you would need an additional FinalBlance being the Dsum() of the tblBalance minus the Dsum() of the tblLeave qty.

Nic;o)

24 1780
nico5038
3,080 Expert 2GB
Guess you need to start with reading the normalization article you can find at:
http://bytes.com/topic/access/insights/
as it's not necessary to update your balance table.
The proper balance can be deducted when needed.

Nic;o)
Oct 5 '10 #2
Mr Hero
16
Hi Nic;o),

I am not sure what you mean by "The proper balance can be deducted when needed." Can you explain a little.

Thanks!
Oct 5 '10 #3
Mr Hero
16
Nico,

I was able to find the Normalization article. The theories of practice makes sense. I am not sure how this will solve my question.

I have created the input table, in which it has all the records for me to pull into a report. The reason I was wonder if the Balance table can be updated, is because I have more then one type of Item. i.e. Chairs has 100, windows has 100, etc. a total of 10 items. How would I update this quantity based on add ins to the stock and removal? There is no specific sequence a record is entered. Lets say I make an entry of 2 Chairs. Since I am adding 2 chairs then how would I create something to update my balance?
Oct 5 '10 #4
nico5038
3,080 Expert 2GB
For getting the balance you'll have to sum the created/bought Item quantity (Let's call it qtyIn in tblIn) and to subtract the delivered quantity (Let's call that qtyOut in tblOut).

As both the tblIn and tblOut will hold the ItemID (chair, etc.) you can JOIN these two tables to the tblItems by the ItemID.

By making the query a group by query you can sum the qtyIn and qtyOut for every different Item and by subtracting them the balance is known.

Getting the idea ?

Nic;o)
Oct 5 '10 #5
Mr Hero
16
That makes sense. =D

Okay, I have one more question. Every two weeks I need this qtyIn to increase by 6. Will I need to write some Code to make this happen? or is it possible to have a qry to this process?
Oct 5 '10 #6
NeoPa
32,556 Expert Mod 16PB
A query can do the update, but scheduling such things is another matter of course. Your specification of every two weeks is far too ambiguous to work from though.
Oct 5 '10 #7
Mr Hero
16
Well, that is interesting, what if I added to a form on the onOpen event to run a query and use the DateDif to calculate the amount of days from the begining of the yr.
Oct 5 '10 #8
nico5038
3,080 Expert 2GB
There's a big disadvantage in automating such an append, as people tend to get the idea they lose control.

I would probably test when starting the application or the last update has been over two weeks ago to pop-up a confirmation for for the user to agree to write the new quantity to the database. I would also have a control table where the user can set their increment, thus any future changes don't imply changing the code.

This code will of course trigger an append query to insert the quantity.

When you add these quantities into the future, then don't forget to make the query for calculating the balance dependent on the current date.

Nic;o)
Oct 5 '10 #9
Mr Hero
16
Hmm... Thanks for the guidance, I will continue and see how this turns out.
Oct 5 '10 #10
Mr Hero
16
Okay, I am not having much luck. Do know where I can look at an example?
Oct 5 '10 #11
nico5038
3,080 Expert 2GB
Just make sure you have in the tblIn a date/time field [LastUpdated] with Now() as default value.
Now you can use a DMAX() to check the difference between the current Now() and the max stored value.
Next use the command:
currentdb.execute (" here goes your query")
to insert the rows.

Nic;o)
Oct 5 '10 #12
NeoPa
32,556 Expert Mod 16PB
This is exactly what I was referring to when I talked of the ambiguity of scheduling the job every two weeks.

Nico has explained the solution, that I would think is probably the better one, well.

Let us know if you manage to get that working or whether you need further clarification. Remember, we don't know how much you know, so unless you tell us we will assume you have it all ok now.

BTW. The article referred to can be found at Normalisation and Table structures, and is well worth reading.
Oct 6 '10 #13
Mr Hero
16
I have hit a few stops. Nevertheless, I think I know where I went wrong.

I have a little experience with Access. However, I would say my experience level is intermediate.

Thanks for taking the time to assist me. =D I will keep you posted on as I attempt to make this work. Thanks.
Oct 6 '10 #14
Mr Hero
16
Okay, it seems to me that I am lost... I wasn't sure how to use the DMAX() function in my qry. I have attached a sample where I am testing everything that I am suggested. I really would appreciate some assistance. Thanks!!
Attached Files
File Type: zip Sample.zip (25.5 KB, 125 views)
Oct 6 '10 #15
nico5038
3,080 Expert 2GB
I've started with changing your table structure. (Check the database relations!)
A tblAgent has been added to record the UpgradeQuantity.

The table tblBalance has an additional date and the NormalBalance has been dropped as "Starting balance as of 1 January" can be recorded on that date as a DateUpgrade qty while dropping the older dates.

Opening the form triggers the warning and a Yes will add the rows with the upgrade qty.

Finally the Balance on the form is made visible after selecting the Agent.

To finalize this you would need an additional FinalBlance being the Dsum() of the tblBalance minus the Dsum() of the tblLeave qty.

Nic;o)
Attached Files
File Type: zip Sample(2).zip (63.5 KB, 95 views)
Oct 6 '10 #16
MMcCarthy
14,534 Expert Mod 8TB
For more information on Table Structures check out this insights article.

Database Normalization and Table Structures
Oct 6 '10 #17
Mr Hero
16
A million thanks for your help. I appreciate your patience with me, as I am still learning and trying to wrap my head around Access.
Oct 6 '10 #18
nico5038
3,080 Expert 2GB
Patience is my middle name :-)

Success with your application !

Nic;o)
Oct 8 '10 #19
Mr Hero
16
I have made some progress, I ended up making some changes due to a recent step back... I do like the problem solve phase. However, It is the implementation part that always gets me confused. Is there way, I could convert some of this process into an event? or it is a best practice to use a qry in conjuction with VBA?
Oct 13 '10 #20
nico5038
3,080 Expert 2GB
You can't change processes into events, you need to use the event to trigger a process or give the user a button to activate a process.

Queries from VBA are in general slower as stored queries, thus I prefer to store them, but use VBA queries when there's too much flexibility needed.

Nic;o)
Oct 13 '10 #21
NeoPa
32,556 Expert Mod 16PB
Nico:
Patience is my middle name :-)
That's right. How many times have I heard them say, while pointing at Nico :- "That's 'im. Patience."
Oct 14 '10 #22
Mr Hero
16
Thanks Nico! I appreciate you taking the time to explain some these issues.

I have a question, can I use type casting in a event to store without getting a data type mismatch?
Oct 18 '10 #23
nico5038
3,080 Expert 2GB
Looks obvious to me, that you make sure that the data to be inserted is in the proper format. In Access you use "nothing" for numbers, quotes (") for text and hashes (#) for the date datatype. The verification can be done by code, the type is determined by the used separator.

Nic;o)
Oct 18 '10 #24
Mr Hero
16
Thank you.
Oct 19 '10 #25

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

Similar topics

7
by: Philip Mette | last post by:
I have been searching many postings and I cant seem to find anyone that has this answer so I decided to post. I am using SQL (Transact-SQL).If I have 2 tables with columns...
2
by: Colm O'Hagan | last post by:
Hi there, I having a problem with a database I'm setting up, I would be delighted if someone out there could help. The database I'm setting up is a task register datebase, it will be used to...
2
by: fkealty | last post by:
I'm attempting to make a small user database more efficient. I have an employee table with id numbers, last name first name title and address. Using a combo box I select the last name and have...
6
by: cyoung311 | last post by:
I'm trying to do an automatic update of one table from another through a form. Basically, when a selection is made for an item, in this case a particular workshop, I want to get the associated...
2
by: vorley99 | last post by:
I am trying to write some VB to copy the field names from one table in a db to a field in another table in the same database i.e., so they appear as a set of records. Any clue how to achieve...
1
by: Dreamerw7 | last post by:
Hi, I know this is probably a dumb question, but here goes: I have 3 tables: REGION REG_ID REGION
10
by: Forest14 | last post by:
Hello! Happy Christmas/holidays to you all I have this huge table named "Positions" with more than 160 fields of which the fields are named with non obvious abbreviations. I have another table...
7
by: underground | last post by:
I wonder if possible on page load to query the value of a specific colmn and insert the result into another table. My query looks like so <? include("include/session.php"); ?> <? $usr =...
1
by: boss1 | last post by:
hi all, i m new in php.i have a problem that is i m using a php form where i can retrieve one field value from one table in oracle db by ajax and its working properly. but i need to insert the...
3
by: dbdb | last post by:
hi... i have a text box in the form, then i want the data is insert into another table. thank you.
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...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.