Carl Colijn
New member
- Local time
- Today, 14:38
- Joined
- Jun 25, 2013
- Messages
- 4
Hi all!
TL;DR: I've got a bound combobox on my continuous form. The combobox is bound to a field from the form's record source (an ID field), but it shows data from a helper lookup query (based on a second table), that translates the bound ID field to a description value. It's thus showing other data than the bound field, and that other data is not in the form's record source either. When the user sorts the form in Access 2010 on this combobox field, the records become non-updateable. Removing the sort makes the records updateable again. This problem didn't occur in Access 2003.
I've already found the source of this problem: Access 2010 has become stricter in when a recordset is still updatable. Since the data shown by the combobox isn't in the form's record source, Access probably must makes a temporary join on the form's record source with the lookup query used by the combobox in order to sort the form on that looked-up data. Since the data returned by the lookup query doesn't contain a primary key from the underlying table (the table doesn't even have one
), Access 2010 decides it cannot safely identify the record being edited through this temporary join, and makes the resulting joined record set non-updateable. Access 2003 (and presumably 2007 from what I've heard) aren't that fussy and do allow updates.
The obvious solution is to set a primary key on the ID field in the lookup table. This does work wonders, but it is not possible with my database, since the ID field cannot satisfy the uniqueness a primary key desires. In the lookup table there is also another ID (historical period ID), which together with the ID used could be used as a composite primary key, but this in turn will not work either because the combobox only uses the ID field and not the period ID field. Adding the period ID to the lookup query and even the combobox's displayed columns doesn't make Access 2010 happy enough either.
It's an interesting puzzle... The Access application is split into multiple central backend databases containing only tables and all data (per period ID), and locally installed frontend databases containing all queries, forms, VBA and the linked tables. Making changes to the frontend would necessitate all clients to update (lesser evil), and changing the table definitions would mean a complete data overhaul in all backend databases AND updating all clients (greater evil). I can set/clear indices and/or primary keys on the backend tables (not evil at all!), but I fear I cannot fix this problem with that alone... Oh, and it must remain in Access 2003 format since I've also got 2003 clients
I know I can fix this, but it will involve some of the greater evils in the aforementioned list. Can anyone come up with the simplest / least invasive answer?
I've attached a sample database showing this problem; I've described it's design below. It's a tremendously oversimplified version, but it does demonstrate the problem described. None of the tables have primary keys defined. The field PeriodID allows me to keep old records in the database, but to also be able to show only records from a certain period (or the current period which is defined as PeriodID = 0). As said, I can assign a (composite) primary key in table T_Items on both fields PeriodID and ID, but not the field ID alone. The problem arises when the user opens the form F_Comments, puts the cursor on control 2 (the combobox using query Q_AllItems_ByName as row source), and then sorts the records - after that, the form becomes read-only.
Table T_Items - all defined items
Query Q_AllItems_ByID - all items sorted by their ID
Query Q_AllItems_ByName - all items sorted by their name, used for name lookup on form
Form F_Settings - changes database settings
Thanks in advance!
Carl Colijn
TL;DR: I've got a bound combobox on my continuous form. The combobox is bound to a field from the form's record source (an ID field), but it shows data from a helper lookup query (based on a second table), that translates the bound ID field to a description value. It's thus showing other data than the bound field, and that other data is not in the form's record source either. When the user sorts the form in Access 2010 on this combobox field, the records become non-updateable. Removing the sort makes the records updateable again. This problem didn't occur in Access 2003.
I've already found the source of this problem: Access 2010 has become stricter in when a recordset is still updatable. Since the data shown by the combobox isn't in the form's record source, Access probably must makes a temporary join on the form's record source with the lookup query used by the combobox in order to sort the form on that looked-up data. Since the data returned by the lookup query doesn't contain a primary key from the underlying table (the table doesn't even have one

The obvious solution is to set a primary key on the ID field in the lookup table. This does work wonders, but it is not possible with my database, since the ID field cannot satisfy the uniqueness a primary key desires. In the lookup table there is also another ID (historical period ID), which together with the ID used could be used as a composite primary key, but this in turn will not work either because the combobox only uses the ID field and not the period ID field. Adding the period ID to the lookup query and even the combobox's displayed columns doesn't make Access 2010 happy enough either.
It's an interesting puzzle... The Access application is split into multiple central backend databases containing only tables and all data (per period ID), and locally installed frontend databases containing all queries, forms, VBA and the linked tables. Making changes to the frontend would necessitate all clients to update (lesser evil), and changing the table definitions would mean a complete data overhaul in all backend databases AND updating all clients (greater evil). I can set/clear indices and/or primary keys on the backend tables (not evil at all!), but I fear I cannot fix this problem with that alone... Oh, and it must remain in Access 2003 format since I've also got 2003 clients

I've attached a sample database showing this problem; I've described it's design below. It's a tremendously oversimplified version, but it does demonstrate the problem described. None of the tables have primary keys defined. The field PeriodID allows me to keep old records in the database, but to also be able to show only records from a certain period (or the current period which is defined as PeriodID = 0). As said, I can assign a (composite) primary key in table T_Items on both fields PeriodID and ID, but not the field ID alone. The problem arises when the user opens the form F_Comments, puts the cursor on control 2 (the combobox using query Q_AllItems_ByName as row source), and then sorts the records - after that, the form becomes read-only.
Table T_Items - all defined items
- field ID: text - the item's ID
- field Name: text - the item's name
- field PeriodID: number - to which period this entry belongs
- field ID: text - the item this comment is for (many to one)
- field Comment: text - the comment
- field PeriodID: number - to which period this entry belongs
- field CurrentPeriodID: number - the selected period to work with
Code:
SELECT *
FROM T_Comments
WHERE PeriodID IN (SELECT CurrentPeriodID FROM T_Settings);
Code:
SELECT ID, Name
FROM T_Items
WHERE PeriodID IN (SELECT CurrentPeriodID FROM T_Settings)
ORDER BY ID;
Code:
SELECT Name, ID
FROM T_Items
WHERE PeriodID IN (SELECT CurrentPeriodID FROM T_Settings)
ORDER BY Name;
- bound to T_Settings
- control 1: editbox bound to CurrentPeriodID
- bound to Q_AllComments
- control 1: combobox bound to field ID, using Q_AllItems_ByID as row source
- control 2: combobox bound to field ID, using Q_AllItems_ByName as row source, bound to column 2 showing only column 1
- control 3: editbox bound to field Comment
Thanks in advance!
Carl Colijn