SubForm

G

Guest

HI All,

I am hoping someone can help, I have two problems with a subform. I need to
have a subform which is connected to the parent form by a field for example
"code" field however I do not want the subform to automatically display the
previous record for this "code" I want it do display a new record with the
code field on the subform populated with the value entered in the parent code
field.


I also need to have set the value of a field on the subform to equal that
on the parent form. For example if the item number on the parent field is
entered as C118, I need the field on the subform to automatically equal this
value. Is this possible as so far everything I have tried has failed.

Both problems are more or less the same but any help or guidance would be
gratefully appreciated.
 
B

BruceM

A little more punctuation might have helped, but I think I get the idea.
Tables contain fields. Forms contain controls that are bound to the table
fields. You need to establish the proper relationship between the
underlying tables. When that is done the linked field will not need to be
populated through the subform, but will contain the same value as the
related field in the main table.
To see only the new record (and not be able to see previous records) set the
form's (or subform's) data entry property to Yes. This setting is located
in the form's Property Sheet (View > Properties). To open to a new record,
add the following to the form's Open event:
Me.Recordset.AddNew
I think DoCmd.GoToRecord , , acNewRec does the same thing. Not sure what
the difference is.
As for setting a field in the subform's record source to be the same as a
field in the main form's record source, there is probably no need. If you
want to see the value of a field copied to the subform you could use code to
refer to the control, but there are a lot of possibilities, and you have
provided few details.
More information is needed. It would help, too, if you describe a bit more
about the database's purpose.
 
G

Guest

Thanks for replying Bruce, the form is used to keep a record work carried out
on equipment, the main form would open to allow the user to add details of
the work carried out, the sub form is used to add details of the equipment
used to carry out the work. Therefore each record for both the subform and
the main form must be unique and not over written.

The main form is linked to the work table and the sub form is linked to the
equipment used table. They have a common field called equipment number, as
I will need to be able to query later to see what equipment had work carried
out on it by any given tool / equipment.

Therefore when the main form and sub form opens in add only mode, the user
must enter the equipment number on the main form in the equipment number text
box linked to the equipment number field in of the underlying table after
completing the main form. He then must complete the equipment number in the
sub form.

To avoid this how could I get the equipment number to appear automatically
in the sub form when the user enters the number in the main form.

Rgds

Nora.
 
B

BruceM

Are you saying that there is a one-to-one relationship between the tables?
Further, are you saying that one piece of equipment (and one piece only) is
used to perform the work on a piece of equipment? Can there be more than
one record in the subform's record source for each record in the main form's
record source. What equipment details are you talking about? Is there an
equipment table, or are you creating a new record each time you use a
particular piece of equipment?
Have you established relationships between the tables? If so, what is it?
Please post the relevant fields from the two tables. It would help, too, if
you describe a bit more fully what you need to do. For instance, the
meaning of "details of the equipment used to carry out the work" is not
clear. What sorts of details?
In general, if there is one (and only one) record in the subform record
source for each record in the main form record source, there may be no need
for having two tables.
 

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