Linking a Subform with a command button

B

Boris

I have a Main Form and want to link it to other 2 Sub forms through a command
button that open this subforms, since I don´t want to visualize both sub
forms all the time. The thing is that when I use the wizard and specify the
target id fields, my sub forms show all records and not only the records that
relate to the record that is selected in the Main Form, so if I enter new
information on the Sub forms this record is not going to be related to any
record of the Main Form. I’m using Access07. Also, when I do it like this, in
the Sub form properties in the data tab there no fields for the master and
child references.
 
K

Klatuu

The Link Child/Link Master fields do not relate to the form being used as a
subform, but the the subform control on the main form.

When you create a subform using the wizard, it gives the form being used as
the subform and the subform control the same name. (bad idea, but that is
the way Access does it).

Be aware, you do not address the name of the form directly, you refer to it
as the form object of the subform control on the main form. For example:

Me.SubformControlName.Form.ControlName

The form to be used as the subform is identified in the subform control's
Source Object property, so when you want to change which form is being
displayed in the subform control:

Me.MySubFormControl.SourceObject = "NameOfTheForm"

Note: if the two subforms don't relate on the same field names, you will
also have to set the LinkChild and LinkMaster properties as well.
 
B

Boris

Yes, forgot to mention I´m a begginer on this and don´t have programming
experience. What im trying to do is putting a command button to open a form
related to my main form, that shows only the records related to the record
that I have open on my main form, but that not only shows me those records
but allow me (as with a subform) to add to those records in relation with the
first.

Till now I have only been able to make a command button that opens the other
form and only shows the records that are related with the record thats
showing in my main form (the one where im putting the command button), but it
does not allow me to add new records that are related (linked) with the
record that I have in my main form. I know that I can do this with the wizard
for making forms, but the linked subform does not maintaind a format that I
desire, and in one case I need 2 separate buttons for 2 separate subforms,
which the wizard do not understands.
 

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