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

Combo box error

Status
Not open for further replies.

tlaksh

Programmer
Feb 25, 2001
98
0
0
US
I have a table with two columns in SQL linked to a Access 97 form. One of the column is a Primary Key. This column is a combo box on the form. When the form opens it is in view mode. But when i move between the records in the combo box..it does not change the other column info and assums that i am inserting a duplicate record and cribs and raises a error that primary key check conditions have been voilated.

But when i use the navigation bar to move between records everything is fine. I don't want the navigation bar on the form.

Where am i going wrong...I am a amature with access...Thanks for ur help in advance.

 
When you change the value in the combobox you try to change the value of the primary key.

If you want to use the combobox to change record you have to remove the Control Source of the combobox but keep the Row Source. Then you have to write code (AfterUpdate on the combo) that change the record.
 
How will this code be? Any suggestions

Thanks
 
The easiest way is to use sub forms. Create a form that shows the data you want to see after choosing a combo box entry. Then, on you main form, put the combo box in the form header. Put the sub form just created in the main form area. Select properties, data tab: Link child Fields: set to the name of the primary key field; Link Master Fields: set to the control name that drives the combo box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top