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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question About Primary Key Value/record number

Status
Not open for further replies.

AlastairOz

Technical User
Jul 27, 2010
81
AU
I have a combo box which looks up its values from a table. I set the bound column in the combo to the id field of that table.
When I update the table in the form with these values, it appears like the value stored in the destination table is a Record Number, as it is not the same number as the auto inc number I can see in the source table for the combo boxes.

It all seems to work OK, when I navigate through the form, the various combo and text boxes display the correct information.
Is this normal and OK?
 
From your description I don't see what values you look at and expect to be different.

If you bind to the id field of a table, that is what the vallue of the combobx will be and thus, what will be stored in the controlsource.

Eg a table orders with an ordertypeid foreign key and a listbox displaying the table ordertypes with name and id, you bind to id and you will store the ordertype.id into the orders.ordertypeid field, which will be okay.

You need to set both recordsource to ordertypes, boundcolumn to id and controlsource = orders.ordertypeid to have the connection correctly.

Bye, Olaf.
 
Ok let me explain,
I origionally had the record source type of the combo box set to alias. The bound column was the key field for that alias.
When I updated the foreign key field in the main table with that key, that would store that value in the main table. This is OK. However, in the combo box after the update, I
would see the key value displayed in the combo box as I move around the main form. I wanted to see the pretty name.
So I set the combo record source to fields. In the row source I added the PK and the pretty name eg: alias.pk,field2,field3
etc.
So after doing an update to the main form I would see the pretty name in the combo box like I wanted, but the value in the foreign key field was not the same
as the actual value of the combo source, I think it is the underlying record number from the index.
That being the case, have I done it right?
 
you set the record source to type fields and put the one field at first you want to see on the elapsed combobox. eg alias.field2,field2,pk with columncount 3 and columnwidths 100,100,0 (adjust approrpiately). Then set boundcolumn to 2.

If you had the pk as first field what you see is that pk, not a recordnumber.

Bye, Olaf.
 
Thanks,
I understand that. And it was working. But as I have explained, the foreign key field in the main table is not getting updated with the actual value I SEE in the foreign tables PK field.
What I see in the main table foreign key field is some other number, I think is the record number.
 
OK I have fixed it.
I had the "Bound To" option set .T.
Set that to .F. and now its OK,
Thanks, Olaf

Alastair
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top