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

Subform one-to-many relationship

10
Dear ladies and gents,
I am quite disoriented while trying to do something.
I have developed a database in access, creating only unbound forms that on opening retrieve recordsources of the controls from the tag and connect to the tables through ADO recordsets created (where in editing mode) as keysets with an optimistic lock.
Now the problem i have is with a form like an invoice. The main form binds to the data table containing the information of the invoice itself. Then there should be a subform where you insert the items connected to that specific invoice.

Problem: how to allow the user to edit items in the list?

One condition is that for no reason i would create a subform with parent child connection since this would mean that when you open the invoice form, the subform gets from the remore database all the items connected to all the invoices created since the stone age, and then graciously shows just the ones related to the present invoice (it would take some hours I guess).

So what i did is populating the subform with a parameter query. But the point is that a subform populated with a parameter query doesn't accept any update (at least this is what happens to me).

I have a workaround which is creating an interface that let the user believe he is working on the data of the subform but in reality the program, when the user presses update, goes back to the back end database, deletes the old row and insert a new one with the new/corrected data (no matter if the user just changed the quantity for an already present item).

Am I too far from the correct way to approach the problem?
I will be grateful for any piece of advice. Thank you
Jacopo
Jul 29 '07 #1
4 2487
nico5038
3,080 Expert 2GB
I seldomly use unbound forms, as Access does quite a good job in preventing concurrent update and the chance of two users accessing the same data in general is very small.
The Mainform/subform when linked is effectively performing your parameterized query already by collecting only the invoicelines of the mainform's invoice :-)

In your case I would probably create a temp table that's filled with the rows linked to the mainform's image. When the user presses [Save] a delete * from tblInvoice where InvoiceID = Mainform.InvoiceID and an insert of the table can be used.
For a multiple user situation you'll need to add the UserName to the unique ID of this temp table. You'llalso need to check or there has been no other user that has updated the Invoive and/or lines before executing this operation.
Getting the idea ?
Guess you understand now why I try to leave this to Access :-)

Nic;o)
Jul 29 '07 #2
Jacopo
10
Dear Nico,
thank you very much for your kind and competent reply.
I understand what you mean and you are right, if Access can take care of all the concurrency problems is quite better.
You are giving me a precious information that I didn't find on any of the Access books I have or on any website I visited so I want to make sure I got it right because it is crucial.

What I thought it was the process related to filling a subform:
1)The front-end application asks to the back-end database all the records of the many side table, in this case the items related to the invoices.
2)Once received ALL the records of all the invoices (several KB, maybe MB of info) the front-end form filters them according to the main form ID.

What instead you are telling me instead is that:
1)The front -end application implicitly compiles a parameter query and sends this to the back-end thus retrieving just the few related records (few KB to be transmitted through the net).
2)Once received the records the subform shows them without any further filtering.

Did I get it right? If so do you have any document or link where i can better understand the process of communicating between backend and frontend when any request of information is sent?
Thank you for any help you can give me.
Jacopo
Jul 30 '07 #3
nico5038
3,080 Expert 2GB
Dear Nico,
thank you very much for your kind and competent reply.
I understand what you mean and you are right, if Access can take care of all the concurrency problems is quite better.
You are giving me a precious information that I didn't find on any of the Access books I have or on any website I visited so I want to make sure I got it right because it is crucial.

What I thought it was the process related to filling a subform:
1)The front-end application asks to the back-end database all the records of the many side table, in this case the items related to the invoices.
2)Once received ALL the records of all the invoices (several KB, maybe MB of info) the front-end form filters them according to the main form ID.

What instead you are telling me instead is that:
1)The front -end application implicitly compiles a parameter query and sends this to the back-end thus retrieving just the few related records (few KB to be transmitted through the net).
2)Once received the records the subform shows them without any further filtering.

Did I get it right? If so do you have any document or link where i can better understand the process of communicating between backend and frontend when any request of information is sent?
Thank you for any help you can give me.
Jacopo
Access normaly will fetch all tablerows for filtering the rows needed for the subform, there's no "network load" difference with issuing a parameter query, as that too will trigger Access to do this "table fetch".
The way to minimize network trafic is to use an ODBC database (e.g. the free MySQL) and use a PassThrough query. Such a query will be set as "text string" accross the network and will only return the selected rows.
Access isn't really suited to act as a "true" ODBC database :-(

I guess the description in the helpfile about the PassThrough query will reveal most info about the way a backend database is processed by Access.

Personally I would have started with a "plain" database with bound forms, as that's the fastest way for development. When the performance proves to be too slow I would switch to rebuild the database with unbound forms. Just makea small test database with the amount of data expected and see how good/bad it performs.

Nic;o)
Jul 30 '07 #4
Jacopo
10
Dear Nico,
again ty for your time. First of all it makes sense developing the db in the easiest way and then fix it later on. I am thinking about it, though I personally prefer to struggle on one single form and then when i am sure it works well, easily use it as a template for all the others, rather than going back and changing 50 forms especially after your customer has complained for a slow application.
Also in this case, we are talking about a "parts" table which likely will have up to 20000 records. Imagine that at least 2000 of them have a bill of materials with on average 50 components. The middle many to many relationship table will have likely 100000 records in the long run.

I must admit that you undermined some of my certainties. After your message I read again about the pass through queries. As I remembered they normally apply to back end database other than jet.
Furthermore (maybe I am wrong), your answer looked like denying something that I took for granted, that is that stored queries in access should work like stored procedures in SQL Server. I mean that when you call from the client a stored query on the server side, the stored query processes the rows on the server and passes back just the selected sets of records.
This idea of mine I think that is supported by the fact that any web page, which of course doesn't have any way to post process recordsets, is able to get subsets of data from a remote source.
If this is true I don't see the point of using pass through queries since:
a) there is no difference in sql dialect between client and server, both jet.
b) a stored query on server anyway ensures a pre processing of records.

I will be grateful if you let me know if this idea of mine is wrong and for what reasons, being better to learn from others' experience than from our mistakes.
Thank you again,
Jacopo
Jul 30 '07 #5

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

Similar topics

1
by: (Pete Cresswell) | last post by:
..DefaultView = Continuous Forms ..RecordSource = a query. While the form & subform are open, I can open up the .RecordSource query and see five records. If I insert a record, then re-open...
0
by: Willem | last post by:
On a bound form I have the following code: Private Sub Form_Error(DataErr As Integer, Response As Integer) Select Case DataErr Case 3200 MsgBox "Cannot be removed" Response = acDataErrContinue...
6
by: Tim Marshall | last post by:
Here's the situation. A form, frmSetUp, with a subform control called subExplain with a source object form frmSetUpSubDefineSides. The source object is a bound form, displaying a few records, no...
4
by: Praetorian Prefect | last post by:
I don't know what step I am missing. I have three tables, tbl_A, tbl_B and tbl_C. Common fieldnames for tbl_A and tbl_B is , and is found in tbl_B and tbl_C. On the main form I have a combo box...
30
by: Shannan Casteel via AccessMonster.com | last post by:
I have a subform named "sbfrmParts" with a list of parts along with the quantity and price. I have used a text box in the subform's footer and set the control source to "=Sum(*)". I set the...
1
by: grammy | last post by:
I have a Form with one Subform. After input, I look at the tables, and not all of the info is coming thru.I have looked at the child,master link properties, and they look okay. The main form is a...
2
by: Eric | last post by:
When i bound the other form in my main form. The whole first subform area is covered with white color. But when i bound another form its not shows the whole area in white color. Why my one subform...
2
by: billypit | last post by:
Hi, I have one form in which I have one combobox and one subform. now when I am selecting value from combobox it will show details in subform by filtering from table based on my selection of...
2
by: Element | last post by:
I have a master form with a simple subform that displays line items in datasheet mode. Everything works fine, except that when the subform has the focus, the standard Access sorting and filtering...
3
by: Jozo | last post by:
Dear All, I have main form "Job" and one subform "Offer" In a subform I have combo box Contacts. How can I open form Contacts if I dbl click on a combo box in my subform where condition ID =...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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
Oralloy
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,...
0
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...
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...

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.