PDA

View Full Version : Code a combobox to display list of names but write the ID number to a field



cleteh
01-10-2016, 12:24 PM
I'm having a little trouble getting this to work.....

I have a combobox titled cboClmForw with the current properties:Control Source: FORWARDER_NO, Row Source Type: Table/Query, Row Source: SELECT [Forwarder ASC].[NAME] FROM [Forwarder ASC];

In my Query (Forwarder ASC) it has a field called name in column 1 and Forwarder ID in column 2

My Combobox is on a form titled CLAIM

I want the combobox to display the forwarder names in the box which it currently does. Once the user selects the name from the combobox and goes to the next record I want the value of the Forwarder ID to be written to the field called FORWARDER_NO in the table called CLAIM.

Right now its erroring out because its trying to write the actual name to the field FORWARDER_NO instead of the forwarder ID.

Any help would be greatly appreciated.

jonh
01-11-2016, 04:27 AM
Add the ID to the data source as the first field.
Set number of columns to 2
Change the bound column to 1.
Set column widths to 0.

cleteh
01-18-2016, 09:36 AM
Hi Jon,

Still having a couple issues... first when I start to type in the name of a forwarder I get a box popping up asking for the paramater value Forwarder ASC.ID I was expecting to see the name of the company appear as I was typing it into the combox so the user can select it and then have it display the Forwarder ID in the Claims table in the FORWARDER_NO Field.

In your instructions above for Add the ID to the data source as the first field. I changed the select source statement to SELECT [Forwarder ASC].[ID],[Forwarder ASC].[NAME] FROM [Forwarder ASC];

For Set number of columns to 2 I changed column count to 2

I set the bound column to 1 and set the column width to 0"

If I enter a forwarder that I know is in the list and go to the next record I get an error saying the text you entered isn't in the list.

Im stuck.

jonh
01-19-2016, 03:01 AM
There is something wrong with the sql in your row source. [Forwarder ASC].ID doesn't exist. Check your spelling.


Because the sql is wrong, no records are being returned to the combobox and since you have 'limit to list' turned on any value you enter will result in that 'the text you entered isn't in the list' error.