473,785 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Subform in a subform

I'm designing a db which stores client details but each client has multiple
'occasions'. For each occasion there is a section which has items purchased
(there are sometimes none, sometimes several). But the main difficulity I'm
having is when I try to do stock control stuff to keep track of how many of
each individual item has been sold.

The basis I've got so far is a client table an occasion table, which is linked
to the client ID, which i working fine (ie multiple occasions per client).
There is a big form with client details and in that form is a subform,
containing the occasion stuff.

-->I thought of having another subform within the occasion subform and trying
to make a relationship where multiple items purchased are linked to occassion
ID (and therefore, the client details can be worked out). But this isn't
working. I've tried all sorts of variations on the relationship type and
changing which fieds are linked but I'm not having any success.

Is there a much better approach? Has anyone made subforms in subforms?
Many, many thanks for any help
Alan Bloom
Nov 12 '05 #1
2 7194
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Your subforms set up should mirror your table set up. E.g.:

Clients -> Clients form
Occasions -> Occasions subform on Clients form
Purchases -> Purchases subform on Occasions subform

Your tables should be set up to show their dependencies (foreign
keys):

CREATE TABLE Occasions (
OccasionID COUNTER NOT NULL,
ClientID INTEGER NOT NULL,
OccDate DATE NOT NULL, -- When the occasion occurred
-- other columns ??
CONSTRAINT PK_Occasions PRIMARY KEY (ClientID, OccDate),
CONSTRAINT FK_ClientID FOREIGN KEY (ClientID) ON Clients,
CONSTRAINT UNIQUE (OccasionID)
)
Note: COUNTER is the AutoNumber datatype in JET dbs.

CREATE TABLE Purchases (
PurchaseID COUNTER NOT NULL ,
OccasionID INTEGER NOT NULL ,
ProductID INTEGER NOT NULL ,
-- other columns ??
CONSTRAINT PK_Purchases PRIMARY KEY (OccasionID, ProductID),
CONSTRAINT FK_OccID FOREIGN KEY (OccasionID) REFERENCES Occasions,
CONSTRAINT FK_ProdID FOREIGH KEY (ProductID) REFERENCES Products,
CONSTRAINT UNIQUE (PurchaseID)
)

Link fields between forms:

frmClients sfmOccasions sfmPurchases
- ---------- ----------- ------------
ClientID ClientID
OccasionID OccasionID

HTH,

MGFoster:::mgf
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP8LHloechKq OuFEgEQLH6ACfQW SZS4fMo4B11F27W qHMu6nMgP8An3vR
Y2+tT6HWChxxIEX 0v4LMsAO4
=qm3l
-----END PGP SIGNATURE-----

Maggieanp22 wrote:
I'm designing a db which stores client details but each client has multiple
'occasions'. For each occasion there is a section which has items purchased
(there are sometimes none, sometimes several). But the main difficulity I'm
having is when I try to do stock control stuff to keep track of how many of
each individual item has been sold.

The basis I've got so far is a client table an occasion table, which is linked
to the client ID, which i working fine (ie multiple occasions per client).
There is a big form with client details and in that form is a subform,
containing the occasion stuff.

-->I thought of having another subform within the occasion subform and trying
to make a relationship where multiple items purchased are linked to occassion
ID (and therefore, the client details can be worked out). But this isn't
working. I've tried all sorts of variations on the relationship type and
changing which fieds are linked but I'm not having any success.

Is there a much better approach? Has anyone made subforms in subforms?
Many, many thanks for any help
Alan Bloom

Nov 12 '05 #2
TC
You need to seperate the database design issues, from the user interface
issues.

If a client can have several occasions, and an occasion can have several
items, the classic design would be as follows.

tblClient
ClientID (PK)
name, address etc.

tblItem
ItemID (PK)
name, descrition etc.

tblOccasion
ClientID ( composite )
OccDate (primary key)

tblPurchasedIte m
ClientID ( composite )
OccDate ( primary )
ItemID ( key )

In this case, the composite keys are a little unwieldy. So instead, you
could have:

tblOccasion
OccasionID (PK) (auto#)
ClientID
OccDate
with a "no duplicates" index on ClientID + OccDate

tblPurchasedIte m
OccasionID ( composite )
ItemID (primary key)

Having got the fdatabase design correct, you then focu on the UI issues.
Certainly you could have a main form with clients, a subform with
poccasions, & a subform (within that subform) for the purchased items.

HTH,
TC

"Maggieanp2 2" <ma*********@ao l.com> wrote in message
news:20******** *************** ****@mb-m25.aol.com...
I'm designing a db which stores client details but each client has multiple 'occasions'. For each occasion there is a section which has items purchased (there are sometimes none, sometimes several). But the main difficulity I'm having is when I try to do stock control stuff to keep track of how many of each individual item has been sold.

The basis I've got so far is a client table an occasion table, which is linked to the client ID, which i working fine (ie multiple occasions per client).
There is a big form with client details and in that form is a subform,
containing the occasion stuff.

-->I thought of having another subform within the occasion subform and trying to make a relationship where multiple items purchased are linked to occassion ID (and therefore, the client details can be worked out). But this isn't
working. I've tried all sorts of variations on the relationship type and
changing which fieds are linked but I'm not having any success.

Is there a much better approach? Has anyone made subforms in subforms?
Many, many thanks for any help
Alan Bloom

Nov 12 '05 #3

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

Similar topics

15
24875
by: Rey | last post by:
Howdy all. Appreciate your help with several problems I'm having: I'm trying to determine if the Visit subform (subformVisits) has a new record or been changed, i.e. dirty. The form that contains the subform is named Clients. I have this code in the Add Client btn: If Forms!Clients.subformVisits!VisitDirty = True Then MsgBox "Visit subform is dirty!"
25
10266
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab Control in the form, and in one of the tabs I have a subform (sfmSiblings) in which I wish to list...
1
8521
by: John Michael | last post by:
I have a form that has a subform that has a subform. The subform loads a record based on a combo lookup box in the main form. I'm trying to set a value in the subform based on a value in a subform of the subform. the main Form is called Subform is called Subform in the subform is called
4
7018
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the user enters the last qualifying field on the main form. In one case this works fine, the subform shows the data the user wants to update -- which means showing all the data put in previously (ie showing this via the requery and the continuous...
1
3039
by: MP | last post by:
I have a main form that has a subform which also has a subform: the main form is the first subform is the second subform is When I click on the button »AddNewSubSubRecord« (add a new record in the second subform , the code generates the message: Can't find the field »POG-03 Work Subform« reffrred to in your expression.
9
9701
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a master-child link to the first subform. subform2 - Master Field: subTrainingModule.Form!TrainingModuleTopicSK Child Field: TrainingModuleTopicSK
6
5979
by: DMUM via AccessMonster.com | last post by:
Hello I am trying to pass the name of my subform to a function/sub but I can't seem to get it to work. I am using an autokey function (ctrl E) to unlock text boxes on a subform. I have a few forms in the database that will use this function, so I need to be able to tell the code which form to unlock. What I have is as follows: Public Function akeyEdit()
4
8850
by: Macbane | last post by:
Hi, I have a 'main' form called frmIssues which has a subform control (named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs. A control button on the main form opens a pop-up form which allows me to edit the record in the subform. What I want to happen is for subform with the new edits to be updated on the main form when I close the popup. I'm sure this is a very small bit of code in the the 'On close' event for the popup...
7
12311
by: ApexData | last post by:
I am using the following code in my TabControl to manage subform loads. The code assigns the subForms SourceObject. - Do I also need code to DeAssign the SourceObject when leaving the Tab, I'm thinking the Table will stay open otherwise ??? - Do I also need to use code to Assign the Child&Master Links, or can I just type the names into the subForms Control Property and just depend on the SourceObject to link to Table???
5
4903
by: samdev | last post by:
I have created two combo boxes in a subform.... For example 1. Combo Box State 2. Combo Box City 3. When a state from the Combo Box State is selected, the City combo box updates to reflect the State chosen by only showing cities in that selected state. 4. When I open just the subform it works just fine but when I open the
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10324
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8971
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6739
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
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 we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.