Creating Relationship vs Selecting Raw Source (1 Viewer)

Jonny

Registered User.
Local time
Today, 17:19
Joined
Aug 12, 2005
Messages
144
When is required to create relationships between tables and why is it not enough only select a table in a field raw source?
What am I missing?
 

Jonny

Registered User.
Local time
Today, 17:19
Joined
Aug 12, 2005
Messages
144
By field raw source I mean to SQL code to populate the combobox (or any other control).

Sorry If my question sounds stupid.. but..
When I build a form I bound all fields to various tables, where comboboxes are populated from tables and table are updated from text fields.
In that way I've managed to create a project without creating relationships between tables.

Therefore I do not really understand the purpose of table relationships?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:19
Joined
Oct 29, 2018
Messages
21,468
By field raw source I mean to SQL code to populate the combobox (or any other control).

Sorry If my question sounds stupid.. but..
When I build a form I bound all fields to various tables, where comboboxes are populated from tables and table are updated from text fields.
In that way I've managed to create a project without creating relationships between tables.

Therefore I do not really understand the purpose of table relationships?
Hi Jonny. See if this old article on using the Lookup tab helps explain some things.
 

isladogs

MVP / VIP
Local time
Today, 15:19
Joined
Jan 14, 2017
Messages
18,216
Suggest you read my extended article and hopefully all will become clear!
 

Lightwave

Ad astra
Local time
Today, 15:19
Joined
Sep 27, 2004
Messages
1,521
Referential integrity WILL CATEGORICALLY enforce the relationship between tables across all forms. It also automatically sets up the correct relationship when creating queries.

Lookup tables on forms MAY IF SET CORRECT enforce the relationship between tables and will have to be set correctly on every form the field is shown. When writing queries you will need to set the relationship each time as well which you could get wrong.

Therefore if you have many forms which show the same information it is easier to ensure that all your forms are correct.

But yes you can do it either way but there is more rigor to the former method.

There are systems where referential integrity is VERY important. EG an athlete racing system whereby individuals are allocated race bibs. These bibs exist as paper and are given to each competitor. If you enter a ficticious number in the database problems cascade as a volunteer can't give them the actual race number and a whole load of things start happening... Typically the volunteer draws a new number or gives the next number. Person is then recorded against that number. But he's not in the database against that number so might not have his time recorded.
 

Jonny

Registered User.
Local time
Today, 17:19
Joined
Aug 12, 2005
Messages
144
Thank you , guys , for a comprehensive explanation. While trying to move the existing DB from look-up tables to referential integrity I encountered errors in comboboxes:
The value you entered is not valid for this field access form combobox
However using referential integrity + Combo Box Wizard looks as the right combination to do that.

Looks as the problem that I'm trying to create a structure on existing database..
 

isladogs

MVP / VIP
Local time
Today, 15:19
Joined
Jan 14, 2017
Messages
18,216
If your tables contain 'orphaned' data, you won't be able to enforce referential integrity until that is fixed. Also covered in my article

I think your combo box error may be a different issue
 

Jonny

Registered User.
Local time
Today, 17:19
Joined
Aug 12, 2005
Messages
144
Something weird happens ..
Same raw source using combo box wizard shows readable data and regular look-up shows ID?!
SELECT [Departments].[ID], [Departments].[Dept] FROM Departments ORDER BY [Dept];
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:19
Joined
Oct 29, 2018
Messages
21,468
Something weird happens ..
Same raw source using combo box wizard shows readable data and regular look-up shows ID?!
That's because the Wizard asks you if you want to "hide" the ID column.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:19
Joined
Oct 29, 2018
Messages
21,468
So why when I'm hiding it without the wizard I'm getting an error?
Hi. You'll have to show us exactly what you did before we can have an idea of the "why." Are you able to post a screenshot or sample db?
 

Jonny

Registered User.
Local time
Today, 17:19
Joined
Aug 12, 2005
Messages
144
Posted,

I've added both combos on the form, one is working while the second is not.
What's wrong?

Thank you
 

Attachments

  • test.accdb
    1 MB · Views: 50
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 07:19
Joined
Oct 29, 2018
Messages
21,468
Posted,

I've added both combos on the form, one is working while the second is not.
What's wrong with the first?

Thank you
Hi. Thanks for posting a sample, it helps understand the problem a lot. I can see two problems with your first combobox.



1. The Row Source is different from the second combobox, and

2. The Column Count and Column Widths are also different


Another problem I see with your database is you're using a Lookup field in the Employee table for the Department. This is adding to the confusion.
 

Jonny

Registered User.
Local time
Today, 17:19
Joined
Aug 12, 2005
Messages
144
Hi. Thanks for posting a sample, it helps understand the problem a lot. I can see two problems with your first combobox.



1. The Row Source is different from the second combobox, and

2. The Column Count and Column Widths are also different


Another problem I see with your database is you're using a Lookup field in the Employee table for the Department. This is adding to the confusion.


Eureka,
The main problem in all my combos was "not-applying" 0cm width for a first column!!
Thanks so much!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:19
Joined
Oct 29, 2018
Messages
21,468
Eureka,
The main problem in all my combos was "not-applying" 0cm width for a first column!!
Thanks so much!
Hi. You're welcome. We're all happy to assist. Good luck with your project.
 

Users who are viewing this thread

Top Bottom