Help with a Macro

A

Al H.

Is there anyway to have a subform closed when opening the primary form when
using the setvalue toggle botton?

Currently, when opening the primary form, the subform is showing, I wish to
have it closed until I click on the macro (toggle) to show the form.

I've set up the SetValue correctly but don't know how to keep the subform
closed until needed.

Thanks
 
M

MikeJohnB

Use code in the on load event of your main form. With your main form in
design view, right click on the little box formed in the top left hand corner
by the merging of the two rulers. Select the form properties and click on the
button marked with three dots ... on the right of the on load event, select
code and enter the line below in the vb code editor window.

between the two lines that appear

Private Sub Form_Load()

End Sub

As shown below

Note! only try on a copy of your database

Private Sub Form_Load()
[Your_Subform_Name_Here].Form.Visible = False
End Sub
 
S

Steve Schapel

Hardimon,

It is not clear how you are doing this, i.e. regarding the Visible
property of the subform control, or the Source Object property of the
subform, or something else. Please let us know what you have in your
macro so far.

By the way, as a hint for the future... if you think it is important for
your message to appear in more than one newsgroup (in practice this is
seldom necessary), please cross-post (i.e. address the single message to
both groups), rather than multi-post (i.e. send separate copies of the
same message to each group) as you have done here. Thanks.
 
A

Al H.

Thanks MikeJohnB. Works like a charm. Excellent! It's nice to talk to
someone who has this kind of knowledge. I'm new at this and I really
appreciate your help!
 
A

Al H.

Steve Schapel

Sorry about the double entry. I received a fix from MikeJohnB. It works!
I'm new at databases, not much training, but I love MS Access.

Thanks for everything!
 
S

Steve Schapel

No problem, Hardimon. Glad to hear that you are enjoying Access, and
pleased to know it's working for you.

If I can suggest a slight refinement to the code Mike suggested:

Private Sub Form_Load()
Me.NameOfYourSubformControl.Visible = False
End Sub

Of course, this then means the subform will not be visible when you
first open the main form, but will be visible if you move to another
record on the main form, which may or may not be what you want. If you
want it to not be visible when you move from record to record on the
main form, then you would put the code on the Current event rather than
the Load event.
 
S

Steve Schapel

Hardimon,

Sorry for my unclear post before. What I was envisaging was a situation
where you:
1. Open the form, and the subform is hidden, according to the code we
have been discussing.
2. You click your button, as per your original question, and the subform
is shown.
3. You proceed to another record on the main form => the subform is
still visible... I wondered whether that was what you would want.
 
A

Al H.

Hello Steve,

The response before is exactly what I needed. The main form contains data
that when updated, it sums with other related info (dollars) within a
particular sub-award. I actually have a grandparent, parent, child
relationship. For this problem, I'm using the child as the main form,
checking the sums in the child against the info contained in the parent form.


In the parent form, I have one total amount for each sub-award. In the
child form, I break that amount into sub tasks to add up to the parent form's
amount. This toggle on and off is a double check when entering info in the
child form without having to go back and check the parent form. Also, with
the toggle, it makes the form cleaner. Thanks for all of your help. I'm
quite sure that i'll be asking more questions again. I wish I'd know this
existed before!
 

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