can you hide a sub form?

G

Guest

I have designed two forms... The first details the particulars of a request
and the second details any action plans associated with each request.

I would like to put a control onto the first form which enables the user to
open the action plans form and for access to automatically populate the two
fields that are linked (request_id and trust_name).

I see that this is possible using a subform but I would like the sub form
hidden unless the user specifically wants to enter an action plan (not every
request will have an action plan).

Is this possible? Can I put a button onto the main form that opens the sub
form?

Or should i simply put a control on the first form opening the action plan
form?

If the latter is the case, what code would i need in the request_id and
trust_name fields to pick up the data entered within the request form?

Thanks,

David
 
G

Guest

It's a question of taste if to have a sub form or open a second form.
Keep in mind that if the sub form is not visible it will create an empty
space in the main form

If you decide to continue with a sub form, I would add a new field in the
request table Yes/No field, display this check box in the form, if the user
want to view the plans he/she will have to check the check box, that way if
the user move between records you can always know when to hide and when to
show the plans sub form without requesting the use to click on the button
every time when displaying old records.

Then you can use the code

Me.[SubFormControlName].Visible = Nz(Me.[CheckBoxName],False)

This line of code should be located in two places
1. OnCurrent event of the form
2. AfterUpdate event of the CheckBox
 
T

tina

an easy way to do this, without using any code at all, is to use a tab
control on your main form. bind the main form to the Requests table and put
the controls on the first tab page. create another form and bind it to
ActionPlans table. in the main form, add a subform control (from the Toolbox
toolbar) to the second tab page, set the subform control's SourceObject
property to the name of the second form, set the LinkChildFields property to
the name of the foreign key field(s) in ActionPlan table that link it to the
Requests table, and set the LinkMasterFields property to the name of the
primary key field in the Requests table.

now your users can add/edit/delete request records as needed, on the first
tab, and go to the second tab whenever they need to add/edit/delete an
action plan for the currently displayed request record.

hth
 

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