How to add Data to table and Its sub-table simultaneously in MS Access through VBA? - ms-access-2010

I am very new to MS Access and I don't even know how should I start to approach for the solution.
I have a Table 1, that contains Project No., Part No. and Quantity of parts.
Now I want to transfer this data on button click to two different tables.
Table Order and Table Parts.
Table parts is a sub table of Table Orders
When we add project Number to table Orders, then we get auto-generated ID then based on that Unique ID, Table Parts is linked to it.
As we get ID from Table Orders, we need to create entry into table Parts with that ID that will contain Part Number and Quantity.
Can you please help me this?
I tried creating an append query but its just adding Project to Table Orders, not doing anything with Part No. and Quantity.

Related

Report with four tables for each account

I am struggling in the creation of a report including four tables.
Those tables should be the same for each account. I use just one dataset. When I run the report, the data is good, but tables listing appears wrong.
First all BALANCE DETAIL tables for all accounts selected are listed, then all DEBIT TRANSACTION tables for all accounts selected are listed etc.
For each account the page should show up just like this
Please give me an easy-to-understand answer since I am really a beginner in this sector.
It might be easier to this with 5 separate datasets, but I think you can do it with just on also.
Create on 'main' table on the dataset. use 4 detail rows, 1 column
Group it on accountnumber
In each detail of the main table, insert a new table with the same dataset.
Group those sub-tables also on accountnumber
Add a filter to the subtables. set the subtable accountnumber equal to the outer table account number (you can use the expression builder, but it should read something like this: row['ponum'] equals row._outer["ponum"] )
Good luck!

Deleting duplicate rows in MS ACCESS

I am making a table by combining columns of two tables. But there are few duplicate rows also. How do you delete duplicate rows from MS Access. I tried using the duplicate record query and also tried to use append query. But neither of them worked.
There are a couple of ways you can do this without using the Access wizards:
1. Run a Make Table Query and in the select statement use grouping for every column. If the tables have a unique ID, don't use the ID because that will make every record unique
2. Export a Select query with the columns you want from the two tables to an Excel workbook. Once in Excel go to the Data tab and click on the column header selector and click on the Remove Duplicates button. Make sure you expand the selection if it asks you. Then save and link the Excel Workbook to Access again and do whatever you need to do from there
There are more ways, but you'd have to provide more details as to what you're trying to accomplish

Database schema design options

I'm struggling to decide what database schema to use. One large table, or many small (though more difficult to manage).
I have 10 templates each with their own text fields. I am trying to store the text for the templates in a database and then when the web page is called I will show the correct text in the html template. Because a mixture of these templates are to be in a sequence of screens where you can navigate backwards or forwards, I need to be able to sequence them, I can only think of adding a page_number column. I also would like to re-order them and delete them as necessary using the page_number column.
I was planning to do all this in a web application without the need for a standard folder/web page structure, like a small CMS system.
option 1,
I can create one large table with many columns, lot's of which will be empty, over half with each row. Is this bad?
option 2,
I could create many tables using only the relevant template columns required.
The problem I see with this, is the headache of repopulating a column in each table when I delete a row, because I need to re-sequence a column that represents page numbers. Which I reduce if I use one large table.
I've thought of moving page numbers into another table called page_order but I cannot think of a way to maintain an effective relationship between the other tables if I make changes.
I'm yet to figure out how to re-sequence a column in a database when a row is deleted. Surely this is a common problem!?
Thanks for taking the time to help!
Have one table that contains one row per template. It might look like:
id (INT, auto-increment)
page_order (INT, unique key here, so pages cannot have the same number)
field1 (STRING, name of the text field)
value1 (STRING, contents of the text field)
field2
value2
Then you have to decide the maximum fields that any page can have (N) and keep adding field/value columns up to N.
The advantage of this is you have one table that isn't sparsely populated (as long as the templates have about the same number of fields, even if the names of those fields are different).
If you want to make an improvement to his (maybe not necessary for a small amount of data) you could change field to an INT id and connect it to a lookup table that contains (field_id, field_name).

Use the same sql Server table to do different updates, is there a way to do that?

Im using Asp.net (VB.net), in my Database :
have One table called (Trade), the same rows of this table are used from 3 different users, These users can make different updates on this table, they should see the basic informations of the table (I mean by the Basic, before the table (trade) has been updated)
The problem is here when the first user wants to modify the table's rows, the second and third user cannot see the basic information any more, and if they decide to change or update some data, the first will lose his updated rows..
The data will be overwritten every time the users make updates on the table.
What I want, is to know if there is a way to do like a copy, or an image of the table for the 3 users, and every user can update normally, without creating the same Table with the same rows 3 times??!
Update
My table structure is: Trade(trName, Carrier, POl, POD, Vgp, Qgp) There is no primary key..
Thank you..
Solution to your problem could be two copies of the original table. Show the original table always to the user as the initial data. And in second table keep the updated data always. Now the trick comes here to maintain the log, for that you have to maintain the log table, this table will have all the fields of original table along with one additional column "UserId", this will have the ID of user who has changed the value. Now each time before updating the data, copy it in the log table. If this suits your need then post the fields of your table then we can workout on the table structures.

asp.net dynamic data websites insert of associated tables in the same form

Im trying asp.net dynamic data websites. I have a customers table and a customers-telephones table. The dynamic data website creates 2 separated forms for the insert in these tables, and I need my form to have the insert of the customer and the insert of the telephones to be in the same form for requirements of the buyer. is it possible to modify something to have the insert of these 2 tables in the same form and with only one accept button?
You can either create a nested gridview, or you can de-normalize your data, giving a fixed maximum of phone numbers per customer.
If you say your customers have maximum 3 different phone numbers (e.g. land, mobile and fax) you can just add these as three new columns on the customers table. In that case you will only need one insert (and one form) to add a customer and all his/her phone numbers.

Resources