Share via

Ken Sheriden ComboDemo1 allows for duplicate records

Anonymous
2024-07-15T19:57:41+00:00

Ken, or anyone familiar with Ken's combo demo database:

I know this was from 11 years ago, but it is still a very relevant demo.

I am trying to implement something very similar to the form "frmLocations_Cont_MCB_NatKey". My issue is that the form allows you to create duplicate records. I can change the info for any given location to match the details of different location. In my case, I want to make sure that no two locations point to the same Parish.

I thought FindFirst (location, parish) in the BeforeUpdate event might work in finding any matching record, but FindFirst finds the active record as a match and cancels the data entry. Do you have a solution for this scenario?

I am also curious about using the name fields in your join tables. Given a much larger data set than your Parishes, wouldn't this method slow down the performance given such long PK search strings?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

10 answers

Sort by: Most helpful
  1. Anonymous
    2024-07-16T00:43:23+00:00

    In my case, I want to make sure that no two locations point to the same Parish.

    In that case you'd simply need to include the Parish, District, and County columns in Locations_NatKey in a single unique index.  It would still be possible to have more than one row in Locations_NatKey with the same value in the Parish column, but the parishes would then be distinct entities, which happen to have the same names, but be in different districts.  This would be perfectly valid as some common parish names occur in multiple places throughout England.

    As regards your final paragraph, the inclusion of a 'natural key' model in the demo is simply to show that it can be done, and has two advantages: (a)  correlated combo box controls can be used in continuous forms view without having to use 'hybrid' controls, as is the case with surrogate keys, as illustrated elsewhere in the demo; (b)  it allows simpler queries to be used as these can be based on one table only, rather than having to join all four tables.  In an operational database I would be more likely to use surrogate keys, however, and go the extra mile when building the interface.

    One thing I didn't include in the demo was the use of the NotInList event procedure when using correlated combo boxes.  However, you will find an example of this in DatabaseBasics.zip in my same OneDrive folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    In this little demo file the section on 'entering data via a form/subforms' includes a simple contacts form in which correlated combo boxes are used to select a country, region, then city, the first two being unbound so as to keep the table in Third Normal Form.  The NotInList event procedure of each combo box allows new values to be inserted into the referenced tables, by typing the name of the new country, region, or city into the combo box.  The code in each case is only slightly more complex than would normally be the case.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2024-07-17T15:21:43+00:00

    Thank you for your valuable time and information

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2024-07-16T12:51:07+00:00

    Scott:

    Thank you for your reply. This case is more complex because the form is a "continuous forms" subform, and the combo boxes are cascading. Ken's Combobox Demo file is an excellent example of this scenario.

    Was this answer helpful?

    0 comments No comments
  4. ScottGem 68,820 Reputation points Volunteer Moderator
    2024-07-15T22:50:56+00:00

    My issue is that the form allows you to create duplicate records. I can change the info for any given location to match the details of different location. In my case, I want to make sure that no two locations point to the same Parish.

    I'm not familiar with Ken's specific demo. But a combobox is generally used to select a foreign key value for a related table. That being the case, the basic answer is to set a unique index on the combination of Location and Parish. That will prevent duplications.

    Another tactic is to use cascading combos. Select the Parish first, then filter the Locations combo so it doesn't show locations already assigned to a Parish.

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2024-07-15T21:23:59+00:00

    Just got in and seen this. It's getting late here, so I'll take a look in the morning.

    Was this answer helpful?

    0 comments No comments