Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with Listbox Controlsource and Displays

Status
Not open for further replies.

aregan1

Programmer
Feb 12, 2002
46
US
I'm currently working on an Access subform which is displayed in datasheet view on another form. The subform contains a combobox called "cboResourceType" and a listbox called "lboResourceName" (which is dependant on cboResourceType).

The "cboResourceType" combo box displays the ResourceType just fine. However, the "lboResourceName" listbox displays the numeric bound column, rather than the description field that I want to see. Here's some info on the fields:

1) Subform RecordSource:
SELECT EventResourcesDetails.*, [Resources].[ResourceName] FROM EventResourcesDetails, Resources WHERE ((([EventResourcesDetails].[EventID])=[forms]![MediaResources]![EventID]) And ([EventResourcesDetails].[ResourceID]=[Resources].[ResourceID]));
Redcordset Type: Dynaset (Inconsistent Updates)

2) lboResourceName
RowSourceType: Table/Query
RowSource: SELECT [Resources].[ResourceID], [Resources].[ResourceName] FROM Resources
WHERE [Resources.ResourceTypeID]=[forms]![MediaResources]![MediaResourcesSubform]!ResourceType
ORDER BY [Resources].[ResourceName];
ControlSource: ResourceID
ColumnCount: 2
ColumnWidths: 0",2"
Bound Column: 1

The ResourceName field is displaying the numeric ResourceID rather than the ResourceName (ex. "5", not "VCR"). If I click on the dropdown arrow for the listbox (there is a dropdown arrow, since the listbox is in datasheet view), I see the valid list of ResourceNames that apply to the selected ResourceType (as I should). But if I click on one of these names, the corresponding ResourceID is then displayed in the row.

I tried changing the controlsource from ResourceID to ResourceName. Then, when the subform first appears with data in it, all the listbox displays in each row appear to be fine, with the correct wording instead of the numeric id. But if I click on the dropdown arrow and choose a different option, the numeric ResourceID then appears in the display. And even worse, the numeric ResourceID then gets saved in the ResourceName field of the Resources table, instead of being saved in the ResourceID field of the EventResourcesDetails table! I definitely don't want to be updating the Resources table in this form! My updates are supposed to happen to the EventResourcesDetails table.

How can I always see the valid ResourceName in the listbox display (instead of the ResourceID field), and then save the new ResourceID in the EventResourcesDetails table?

Thanks for your help. (I'm fairly new to VBA, so please keep explanations simple...)

- Anita


 
Just a thought. Has the table already got numbers recorded in the RecordName field. This has caught me previously after fiddling for a few days in list boxes.
 
Thanks for the suggestion, but that was one of the first things I checked for. The Resource table has the correct ResourceID and ResourceName stored in the right columns. Any other ideas? Thanks...

- Anita
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top