How to refresh data in a subform

R

rich

Hello,

I am trying to get a sub-form to refresh it's data whenever the main control
on the main frame changes its value. There should be no updates to any
values on the main form. All values in the sub-form except the FK are
candidates for updating.

My main form has a cbo and a couple text boxes. The cbo is the key to both
the text boxes and all the data in the sub form. Data in the txtboxes comes
from 1 table and represent typical name, addr, pho stuff. Data in the
subform are details from another table. The cbo is the FK to each.

This is how I built the subform.

1. Bound the form to the table and created objects (1 cbo, 3 txtboxes).

2. Built a qry to select the detail data using same FK as #1.

3. I (discovered that I could do this to build the sFrm.) dragged the qry
directly onto the form and a wizard too me through building the sub form.

I call this form from another form via cmdButton.

When the form opens, user is queried for the empID (FK). The form should
open with empID and name stuff on main form and the related details on the
subform. If user selects a differernt key from the cbo on the main, the
details on the sub-form should refresh to match the newly selected employee.

Right now, everything is displayed correctly the first time, but if I select
a new empID from the cbo, the subform does not refresh and I may get a
warning about attempted update that violates PK/FK constraints.

TIA,
Rich
 
M

Marshall Barton

rich said:
I am trying to get a sub-form to refresh it's data whenever the main control
on the main frame changes its value. There should be no updates to any
values on the main form. All values in the sub-form except the FK are
candidates for updating.

My main form has a cbo and a couple text boxes. The cbo is the key to both
the text boxes and all the data in the sub form. Data in the txtboxes comes
from 1 table and represent typical name, addr, pho stuff. Data in the
subform are details from another table. The cbo is the FK to each.

This is how I built the subform.

1. Bound the form to the table and created objects (1 cbo, 3 txtboxes).

2. Built a qry to select the detail data using same FK as #1.

3. I (discovered that I could do this to build the sFrm.) dragged the qry
directly onto the form and a wizard too me through building the sub form.

I call this form from another form via cmdButton.

When the form opens, user is queried for the empID (FK). The form should
open with empID and name stuff on main form and the related details on the
subform. If user selects a differernt key from the cbo on the main, the
details on the sub-form should refresh to match the newly selected employee.

Right now, everything is displayed correctly the first time, but if I select
a new empID from the cbo, the subform does not refresh and I may get a
warning about attempted update that violates PK/FK constraints.


You should not need to do anything beyond setting the
subform control's Link Master property to the main form's PK
field and the Link Child property to the FK field.

I don't understand what you're saying about the warning.
The thing to check though is that you are not using the same
combo to enter data in the main form and to search for a
empID. The search combo really needs to be unbound so it
does not interfere with any data in a table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top