Hi
Hopefully, this is a basic problem that an experienced Access programmer has come across. I have a technical background, but haven't used Access for a while. Sorry this is a tad long, but I've tried to provide as much detail as possible.
I have a simple "new record" form that includes two comboboxes: cboGroup and cboOwner.
Both are populated via select queries, that return more than one row of two columns:
qryListGroup - SELECT subCode, description FROM tblCodeDecode WHERE categoryCode = "GRP". This returns an alphanumeric code and name, e.g. "M", "Master Group". Note that the PK for tblCodDecode is categoryCode + subCode (categoryCode = "GRP").
qryListOwner - SELECT ownerID, ownerName FROM tblOwner. This returns an integer ID and owner name, e.g. 13, "John Smith". PK is ownerID.
The combo properties are identical, other than their row source (qryListGroup, qryListOwner). The Column Count for both is set to 2, Column Widths is set to 0cm;3cm, and Bound Column is set to 1.
In the form's Load event, I set their default values:
Me.cboGroup.DefaultValue = Me.cboGroup.ItemData(0)
Me.cboOwner.DefaultValue = Me.cboOwner.ItemData(0)
before setting focus on the first modifiable field (msgbox displays show these settings are OK).
My problem is that cboGroup shows no default value when the form is displayed, although the rows have been loaded and are loaded into the combo control when the dropdown arrow is clicked.
Meanwhile, cboOwner has all rows loaded, the default value is loaded into the control and the default value is shown as being "active" with a reverse highlight (annoying, but a fix for another day).
Apart from the fact that the first value in cboGroup is alpha (not numeric, as in cboOwner) I cannot for the life of me figure out what is wrong.
I have a nagging thought that it may have something to do with the fact that qryListGroup runs against a table with a 2-part key of categoryCode + subCode, the field subCode being the first column retrieved in the qryGroup, along with the group name in tblCodeDecode.description.
Any suggestions will be gratefully received.
Hopefully, this is a basic problem that an experienced Access programmer has come across. I have a technical background, but haven't used Access for a while. Sorry this is a tad long, but I've tried to provide as much detail as possible.
I have a simple "new record" form that includes two comboboxes: cboGroup and cboOwner.
Both are populated via select queries, that return more than one row of two columns:
qryListGroup - SELECT subCode, description FROM tblCodeDecode WHERE categoryCode = "GRP". This returns an alphanumeric code and name, e.g. "M", "Master Group". Note that the PK for tblCodDecode is categoryCode + subCode (categoryCode = "GRP").
qryListOwner - SELECT ownerID, ownerName FROM tblOwner. This returns an integer ID and owner name, e.g. 13, "John Smith". PK is ownerID.
The combo properties are identical, other than their row source (qryListGroup, qryListOwner). The Column Count for both is set to 2, Column Widths is set to 0cm;3cm, and Bound Column is set to 1.
In the form's Load event, I set their default values:
Me.cboGroup.DefaultValue = Me.cboGroup.ItemData(0)
Me.cboOwner.DefaultValue = Me.cboOwner.ItemData(0)
before setting focus on the first modifiable field (msgbox displays show these settings are OK).
My problem is that cboGroup shows no default value when the form is displayed, although the rows have been loaded and are loaded into the combo control when the dropdown arrow is clicked.
Meanwhile, cboOwner has all rows loaded, the default value is loaded into the control and the default value is shown as being "active" with a reverse highlight (annoying, but a fix for another day).
Apart from the fact that the first value in cboGroup is alpha (not numeric, as in cboOwner) I cannot for the life of me figure out what is wrong.
I have a nagging thought that it may have something to do with the fact that qryListGroup runs against a table with a 2-part key of categoryCode + subCode, the field subCode being the first column retrieved in the qryGroup, along with the group name in tblCodeDecode.description.
Any suggestions will be gratefully received.