Results 1 to 9 of 9
  1. #1
    shani908 is offline Novice
    Windows 11 Access 2019
    Join Date
    Feb 2023
    Posts
    24

    Creating a form, data entry error and Relationship

    Hello everyone.



    I am trying to create a form for data entry, I have three tables as following.

    1) Agents
    2) Company
    3) Propertytbl

    I have the following Properblems. :

    1) All relationship have Data Integrity and Cascade update enabled. I am getting error as shown in the screenshot. I have enable "Data Entry" property to "yes".

    2) I think my database design is wrong. My analogy is following :
    A) One company can have many Agents.
    B) Each Agents can have many listing/Properties.


    Please advise.



    Click image for larger version. 

Name:	CompanyTbl.png 
Views:	26 
Size:	5.9 KB 
ID:	49671Click image for larger version. 

Name:	AgentsTbl.png 
Views:	26 
Size:	6.1 KB 
ID:	49668Click image for larger version. 

Name:	PropertyTbl.png 
Views:	26 
Size:	6.2 KB 
ID:	49667Click image for larger version. 

Name:	Relastionship.png 
Views:	26 
Size:	6.6 KB 
ID:	49669Click image for larger version. 

Name:	Data_entry_error.png 
Views:	26 
Size:	20.2 KB 
ID:	49670

  2. #2
    Edgar is online now Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    With those relationships, each agent can be related to only one property. If you want your properties to be related to only one agent at any given time and also be able to assign multiple properties to any agent, then the design should be as follows:
    Company: CompanyID, CompanyName
    Agents: AgentID, AgentName, CompanyID
    PropertyTbl: PropertyID, PropertyDetails, AgentID

    You should also reconsider your naming convention for tables. The error message probably means there are rows in Agents table with CompanyID values that do not appear in Company table.

  3. #3
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    229
    I agree with Edgar. The question is whether there might be a many-to-many relationship between agents and properties. Then you need an extra junction table.

    The error is probably because companyID and propertyID have a default value of 0. That value does not appear in the tables they refer to.
    Groeten,

    Peter

  4. #4
    shani908 is offline Novice
    Windows 11 Access 2019
    Join Date
    Feb 2023
    Posts
    24
    Thanks .. Noted. its working now. Its started working once I added AgentID to PropertyTbl.



    Quote Originally Posted by Edgar View Post
    With those relationships, each agent can be related to only one property. If you want your properties to be related to only one agent at any given time and also be able to assign multiple properties to any agent, then the design should be as follows:
    Company: CompanyID, CompanyName
    Agents: AgentID, AgentName, CompanyID
    PropertyTbl: PropertyID, PropertyDetails, AgentID

    You should also reconsider your naming convention for tables. The error message probably means there are rows in Agents table with CompanyID values that do not appear in Company table.

  5. #5
    shani908 is offline Novice
    Windows 11 Access 2019
    Join Date
    Feb 2023
    Posts
    24
    Thanks . Noted. Can you please give some more details on that. I am a beginner.

    Thanks

    Quote Originally Posted by xps35 View Post
    I agree with Edgar. The question is whether there might be a many-to-many relationship between agents and properties. Then you need an extra junction table.

    The error is probably because companyID and propertyID have a default value of 0. That value does not appear in the tables they refer to.

  6. #6
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    229
    In theory, it could be possible for an agent to belong to multiple properties and a property to multiple agents. Then you need the extra table containing at least the agent and property IDs.
    Groeten,

    Peter

  7. #7
    CarlettoFed is offline Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2019
    Posts
    255
    Attach an example file and you will see that it will be easy to solve the problem because without being able to see what you have created it is more difficult.

  8. #8
    Edgar is online now Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    Quote Originally Posted by xps35 View Post
    I agree with Edgar. The question is whether there might be a many-to-many relationship between agents and properties. Then you need an extra junction table.
    Indeed. If the business rule is "my properties can be related to one or multiple agents" then the junction table will solve it. OP did not specify it, so the simplest solution is a one-to-many relationship of one-agent-many-properties. A many agents and many properties relationship would look as follows:

    Company: CompanyID, CompanyName
    Agents: AgentID, AgentName, CompanyID
    PropertyTbl: PropertyID, PropertyDetails
    PropertiesByAgent: Id, PropertyID, AgentID

    Which, assuming agents sell the properties, it would allow to add to PropertiesByAgent extra information about this agent-property relationship, such as a date to indicate when the assignment of the property to that seller was made, a field to indicate the commission, another field to indicate status, as well as notes.

    Not knowing further about the business, the OP should clarify.
    Last edited by Edgar; 02-12-2023 at 01:53 PM. Reason: Added and corrected info

  9. #9
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    229
    Quote Originally Posted by Edgar View Post
    Not knowing further about the business, the OP should clarify.
    Once more.............
    Groeten,

    Peter

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 09-11-2020, 02:26 AM
  2. Replies: 3
    Last Post: 08-22-2018, 07:32 AM
  3. Replies: 6
    Last Post: 03-30-2017, 06:55 AM
  4. Replies: 6
    Last Post: 12-28-2014, 08:41 PM
  5. Creating form for data entry
    By salisbut in forum Forms
    Replies: 5
    Last Post: 03-31-2011, 12:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums