Results 1 to 6 of 6
  1. #1
    anthgav is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    86

    Using required and unique on fields linked in relationships

    Hi

    I have a database used for managing warehouse locations. I have a few fields set up in relationships. I make queries from excel into pivot tables which work fine.

    I wanted to enhance the access database by turning on REQUIRED and UNIQUE for some of the fields in Access. When I activate these the existing queries that are set up in Excel pivot tables still work fine. When I want to create a new query I get "Type mismatch in expression" error. I know these errors happen when you have different field types such as short text and a number linked to each other. it also seems I get these errors when using REQUIRED and UNIQUE on fields in a relationship.

    For example I have a table called Warehouse, the index for Warehouse is automatically set to UNIQUE.
    Click image for larger version. 

Name:	Warehouse.PNG 
Views:	17 
Size:	5.5 KB 
ID:	30186



    I also have a table called Area. In Area is a field called warehouse which has a relationship to the index in the Warehouse table. the warehouse field is set to REQUIRED.
    Click image for larger version. 

Name:	Area.PNG 
Views:	17 
Size:	7.8 KB 
ID:	30189

    I have similar relationship fields through out the database.

    Is it possible to use REQUIRED and UNIQUE in relationship fields, if so what can I do to to prevent mismatch errors with them? Perhaps I'm doing something incorrect.

    Thanks
    Attached Thumbnails Attached Thumbnails Area.PNG   Area.PNG  

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Sounds like the value of warehouse in Area table is actually the text description from warehouse field of Warehouse table and not the warehouse_id. This will cause the mismatch error.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    anthgav is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    86
    Thanks for that, what you said is correct. I've had to change all my lookup fields to show ID instead of the description to make UNIQUE and REQUIRE work. All my fields now show the ID.

    Is there a way to achieve using REQUIRE and UNIQUE but to have the description show in the lookup field instead of the ID?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I never set lookups in tables. I build comboboxes on form.

    Either way, set properties:

    RowSource: SELECT warehouse_ID; warehouse FROM Warehouse ORDER BY warehouse;
    BoundColumn: 1
    ColumnCount: 2
    ColumnWidths: 0";1"

    Advise you not give objects/fields/controls same names. I would use Warehouses and Areas (note the plural) as table names.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    anthgav is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    86
    I've been getting my head around making these link without using relationships and I'm finally grasping it using combo boxes. I've linked the tables in the combo box using the warehouse fields so that I get a description name instead of an ID number in the field, is that the correct way of doing it? Also what if I want referential integrity, can I only set that using relationship look ups?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Whether you call it a 'lookup' or a related dependent table, controlling referential integrity requires to either set relationship links in Relationship builder and set the Enforce checkbox for the link or to carefully manage data integrity with db interface design and code.

    If you don't save warehouse_ID as foreign key then it really serves no purpose for this situation and is not even needed in the combobox RowSource.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 7
    Last Post: 07-04-2017, 11:30 AM
  2. Replies: 2
    Last Post: 06-12-2015, 07:03 PM
  3. Queries and relationships with Linked Tables
    By stardust1979 in forum Queries
    Replies: 3
    Last Post: 08-04-2014, 09:53 AM
  4. Replies: 7
    Last Post: 10-04-2012, 01:21 PM
  5. Replies: 1
    Last Post: 08-24-2012, 07:11 AM

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