0
votes

I have a little databes in access. I make a few forms with sub forms and drop list(by query):

enter image description here

Steps of my creating form:

  1. make form from table
  2. delete all not PK or FK text box
  3. create comboBox with store value to text box what I choase
  4. create subForm and set Link Master Fields and child fields

design view:

enter image description here

This is form for table Task task have Fk: Project, peson etc. DropLists are connected tu subform for changing FK like project, person etc. So when I work i select in droplists what i want add to database and work with subForm. When I close this form, the first row in table change FK to last configuration on droplists.. Pleas how can I fix it?

1
Do you have any code behind your form? If so, you should add a breakpoint. It may be difficult to decide where, however. Do you have a close button? How do you close your form? Do you have a Current event? Do you have any code that updates the subform?Fionnuala
NO i do not have any code behind.. , and i do not have any button.. only close form by X on right or right click on heda and chose close.. It is small databes with MS access forms.. realy realy small..Eddy_Screamer
How are the drop lists connected to the subform?Fionnuala
During winzard of combobox i Store that value in field on form ... and Subform have Link Master Fields and Ciheld Fields on form id_projekt;id_os_udaje etc. this is text field what is invisible on form but droplist stor to that values..Eddy_Screamer
Steps of my creating form: 1 make form from table 2 delete all not PK or FK text box 3 create comboBox with store value to text box what i choase 4 create subForm and set Link Master Fields and child fieldsEddy_Screamer

1 Answers

1
votes

It is quite possible to use a main form for selecting and updating subform records, but in this case it should not be a bound form.

To set up, for want of a better word, a linking form, unbind the main form, that is remove the record source and ensure the dropdowns (comboboxes) do not have control sources. I suggest you rename the dropdowns to cbo, to indicate that they are controls, not fields. The hidden controls should not be needed.

The value of a combobox is the value of the bound column. The Key or FK is the first item in your SELECT statement and the bound column is 1 (one) so the relevant Key or FK is the value of each comboboxe. You can set the link master fields to the names of controls so the Link Master Fields should be cbo_id_projekt;cbo_id_os_udaje;cbo_id_komponent;cbo_id_uloha.

As an aside, I generally avoid underscores, but each to their own.