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

Problem: Subform self-editing

Status
Not open for further replies.

thehorse

Programmer
Oct 1, 2004
14
US
I created a basic form with a combobox looking up [OFFICE] with a subform that filters based on [OFFICE] to display editable fields of employees in each office. The form/subform works, but autoedits the first record. What do I mean? When I open the form, it defaults to the first record in the table, say Andy in Office A. I change the combobox to B, which filters to the B office personnel. I close the form. Next time I open the form, it defaults again to Andy (as the first record), but this time he's in office B. Every time I change the combobox, then close the form, Andy's office changes to that office. Get it? Any help?
 
Well, do you have [OFFICE] as a control source in your combo box? If so, try removing it.
 
Ah-Ha! I figured it was something rather simple. Let me see if I understand. By having [OFFICE] in the Control Source of the combobox, the combobox is bound to the data in [OFFICE] which makes it an editable field. This also is causing Andy's record to change based on the edit in the combobox. So, if I sort by offices, in effect I am editing Andy's office record. I restart and find Andy in a different office. By removing the bound source, thus making the combobox unbound, it no longer edits based on that field. Am I close?

My only confusion that remains is when I first built the form/subform, the combobox was unbound. When I added the subform, it would not link to the mainform's combobox stating that it couldn't link to an unbound field. This is why I added the Control Source.
 
Hi, Yes, it's ususally the simple things and you are correct.

A couple suggestions. When I use combo boxes for a sort I usually color them differently or do something to distinguish it as a sort item.

Another way is to use a list box where the form sorts on the item clicked. This works well if the list isn't too long.

The second paragraph - In cases like that, I use an unbound subform and requery the subform in the afterUpdate event of the combo box. It works just as well.

Hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top