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

Relationship problem when inserting records

7
I am making a menu ordering system.

These are the main tables:
MenuByCycle
MenuByCycleID (PK)
Year
CycleID

MenuByDay
MenuByDayID
Day
MenuByCycleID (FK to MenuByCycle)

MenuByDiet
MenuByDietID
TypeOfDietID (PK)
MenuByDayID (PK, also a FK to MenuByDay Table)

FoodPerMenu
FoodByMenuID (PK)
MenuByDietID (FK to MenuByDiet Table)
FoodID

In a year there are 3 cycles.
The Menu changes daily depending on which cycle it is on.
There are different types of diets, and each day there is a food menu for each type of diet.
The MenuByDiet is a junction table between MenuByDay and FoodPerMenu.

Via data sub-sheets it works great but once I make a query to add a record in FoodPerMenu table it creates a duplicate MenuByCycle, and MenuByDiet records.


SQL Code:

In the query I set the Right joins so I could be able to enter data in the fields.
Expand|Select|Wrap|Line Numbers
  1. SELECT MenuByCycle.CycleID, MenuByCycle.Year, MenuByDay.Day, 
  2. MenuByDiet.TipoOfDietID, FoodPerMenu.FoodID,   
  3. FROM ((MenuByCycle RIGHT JOIN MenuByDay ON MenuByCycle.MenuByCycleID = MenuByDay.MenuByCycleID) RIGHT JOIN 
  4. MenuByDiet ON MenuByDay.MenuByDayID = MenuByDiet.MenuByDayID) 
  5. RIGHT JOIN FoodPerMenu ON MenuByDiet.MenuByDietID = 
  6. FoodPerMenu.MenuByDietID;
Sep 29 '08 #1
5 2696
FishVal
2,653 Expert 2GB
Hello, Papote.

Pay attention to the fields retrieved by the query you've posted. Those participating in relationships are all PKs of the correspondent tables. No wonder, form control bound to such a field will add new record to PK-side table rather than modify FK field value in FK-side table.

Regards,
Fish
Oct 1 '08 #2
Papote
7
The retreived fields aren't PKs. Only in the Order by clause.
I have retrieve the fields CycleID and Year from MenuByCycle table and Day from MenuByDay table to make a where statement it shouldn't appear in the end query. I am missing the MenuByDietID field from MenuByDiet table.


Hello, Papote.

Pay attention to the fields retrieved by the query you've posted. Those participating in relationships are all PKs of the correspondent tables. No wonder, form control bound to such a field will add new record to PK-side table rather than modify FK field value in FK-side table.

Regards,
Fish
Oct 1 '08 #3
FishVal
2,653 Expert 2GB
Ok, I've experimented with that a while.
Apparantly, Access join automation creates records properly only if correspondent FK is retrieved within query. Check whether is it so in your query.
Also, relationship between [MenuByDiet] and [FoodPerMenu] tables is not clear.

Regards,
Fish.
Oct 1 '08 #4
Papote
7
This is what I originally had.
zshare.net/download/19770145d4f6257a/
Pass:tester0001.?
Some items are in spanish...

I include a working version of the form used to enter / view the menu MenuByCycleEntry.

I wanted the subforms to link like the MenuByCycle table nested sub-datasheets upto ordering by institution per food menu item.

There are 13 different types of diets for each day.
Each type of diet has it's own menu which contains different food.
Oct 1 '08 #5
Papote
7
I managed to to do this via code. A couple of Ifs and dlookups. Works pretty good controlling the the records that need be created.

I am worried that when I upsize to MS SQL Server 2005, that the Dlookups won't work.
Oct 16 '08 #6

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

Similar topics

2
by: and | last post by:
hi everyone, i am using oracle 9.2.0 and i have written a simple jdbc java program to insert a record within a for loop to a table using jdbc thin driver(refer to the bottom of this email for the...
2
by: Ken Loh | last post by:
Hi All, I'd like to develop something which has a concept like the folders-and-files in your PC. A folder can have subfolders and/or files. The subfolders themselves have the same...
8
by: Andante.in.Blue | last post by:
Hello, I have just inherited a legacy Access 97 database. While going through it, I noticed something strange... its Relationships window (the one accessed by Tools --> Relationships) is almost...
3
by: Leinad Kong | last post by:
I'm using Access 2002, as front-end and back-end as well: 1) I faced database corrupted problems, when more than 1 user edit concurrently. I'm using All-records Locking, and open-exclusively as...
3
by: Shannon Rotz | last post by:
I'm just learning how to use class modules in Access (2000 or XP). So far, I've created two classes, with the data manipulation for the corresponding tables encapsulated inside each of them ...
5
by: BrianDP | last post by:
This is a strange one-- I have an Access 2K database with a split front end/back end. There are two tables in the back end - RFile and RLine. There is a one to many relationship from...
7
by: Ron | last post by:
Hi All, Using Access2000, winXP. Table 1 = tblClients displayed on frmClients via qryClients. 2nd table = tblInvoices shown on frmInvoices via qryInvoices. 2nd table = tblDetails shown on...
3
by: shawnews | last post by:
Ok...I'll first describe briefly what I've done. Working from a paper form with over 200 fields - broken into 10 areas, I created a database with 10 tables. I then created a form using those 10...
4
by: PW | last post by:
Hi, I set up a relationship between two tables with the itineraryid fields in both tables: tblDailyItinerary tblDailyMeals I have a form that writes a record to tblDailyItinerary that...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.