Auto input data in a field in a form using relationships (1 Viewer)

18khattaba

New member
Local time
Today, 19:16
Joined
Jan 8, 2023
Messages
5
I have two tables and one is for customers and the other is for prices of hotels. For every location, there is one hotel. In the customers form, I wold like it to auto select the hotel when the user selects a location. I would like to do this using relationships.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:16
Joined
May 7, 2009
Messages
19,245
create a "junction" table between locations and hotels.
if there is 1-1 relation (one hotel for each location) then you only
need 1 table.
 

jdraw

Super Moderator
Staff member
Local time
Today, 14:16
Joined
Jan 23, 2006
Messages
15,379
18khattaba
Are you trying to support some sort of business with this proposed setup?
What are the "rules of that business"?
What Locations are involved?
Who are the current/proposed Customers?
What is your activity with respect to those Customers?
One or more Hotel(s) per Location?
Prices by Room by Occupancy (Number persons * Days) or what?

You need to know the business rules in order to establish and confirm your relationships.
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:16
Joined
Sep 21, 2011
Messages
14,310
Answered on the other site.
 

18khattaba

New member
Local time
Today, 19:16
Joined
Jan 8, 2023
Messages
5
I have created 3 tables linked in a relationship, then I created a query to put all that data in a single table. The tables are called BookingTBL, Customers and PriceOfHotels. I have used the query to make a form the price of hotels table should not be updated but only viewed to retrieve information from it. How can I get the form to add information based on the product and what the user inputs.

So if the user selects they want to go to Belfast it should automatically select the hotel "The Belfast". Also, how can I do this in a way where the user can see what hotel and the price of it in a field that is locked.

I can't do a combo box as the table looks like this and so it will show like 4 of each location which doesn't look nice also, the user has to input which location and the type of hotel which could cause a problem when selecting.

This is the price of hotels table:
1673306184244.png
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:16
Joined
Oct 29, 2018
Messages
21,474
I have posted another thread that explains it better.
Hi. Welcome to AWF!

No need to do that. To avoid any confusion, I have merged your two threads on the same topic.
 

jdraw

Super Moderator
Staff member
Local time
Today, 14:16
Joined
Jan 23, 2006
Messages
15,379
Is this a school assignment? If not, could you describe the requirement in business terms?
Showing us a table and some values without a business context isn't helpful to get a focused response.
You may want to review some database concepts : Normalization, Relationships, Business Rules

Please see this Hotel Bookings Reservation page (data model and rules) by Gina Whipp
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:16
Joined
Sep 21, 2011
Messages
14,310
I have created 3 tables linked in a relationship, then I created a query to put all that data in a single table. The tables are called BookingTBL, Customers and PriceOfHotels. I have used the query to make a form the price of hotels table should not be updated but only viewed to retrieve information from it. How can I get the form to add information based on the product and what the user inputs.

So if the user selects they want to go to Belfast it should automatically select the hotel "The Belfast". Also, how can I do this in a way where the user can see what hotel and the price of it in a field that is locked.

I can't do a combo box as the table looks like this and so it will show like 4 of each location which doesn't look nice also, the user has to input which location and the type of hotel which could cause a problem when selecting.

This is the price of hotels table:
View attachment 105649
Never heard of Distinct or Group By?
Your db does not appear to be normalized, hence all your problems.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:16
Joined
May 7, 2009
Messages
19,245
see this demo if it will be of help to you.
 

Attachments

  • dbHotelCal.accdb
    704 KB · Views: 86

18khattaba

New member
Local time
Today, 19:16
Joined
Jan 8, 2023
Messages
5
see this demo if it will be of help to you.
Thank You. This is very helpful and I now understand on how to do it but I would like to know what these tables are, where did they come from and what do they do to the actual database.
1673387908127.png
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 14:16
Joined
Feb 19, 2002
Messages
43,276
They are Access system tables that YOU do not update directly. It is a bug with Access that they show in the relationships window at all. You can get rid of them by deleting all three tables from the window. This does not delete the tables from the database. It simply removes them from the relationships window. If you press the show all relationships button, they will pop back on again.
 

18khattaba

New member
Local time
Today, 19:16
Joined
Jan 8, 2023
Messages
5
They are Access system tables that YOU do not update directly. It is a bug with Access that they show in the relationships window at all. You can get rid of them by deleting all three tables from the window. This does not delete the tables from the database. It simply removes them from the relationships window. If you press the show all relationships button, they will pop back on again.
Thank you I now have a better understanding of it 😃😃😃
 

Users who are viewing this thread

Top Bottom