Adding a record to a subform with a macro

S

sg

I have a main form with a subform. The main form is called PT Test frm, the
subform is called Fail subfrm. They are linked with the field PT ID. I have
a field on the main form that is a combo box. The two choices on the combo
box are either Acceptable or Not Acceptable. When I choose Not Acceptable, I
want the subform to open so I can enter information about what was
unaccepatble. I've tried to set a condition for the field being set as Not
Acceptable and then used the Open Form action. The record is not being
saved, however, because the PT ID field is not being populated in the
subform. I've also tried adding a run command action to add a record but it
is just not doing anything when I do that.

I've attached the macro to the On Lost Focus and After Update properties of
the form, but nothing is working. If anyone out there can help me, I would
really appreciate it! Thank you in advance.
 
S

Steve Schapel

Sg,

It is not really clear what you are doing. Part of the problem is that you
appear to be using the word "subform" in a non-standard way. Normally a
subform is a control on a form, into which another form is contained. So
therefore "I want the subform to open" doesn't really apply. And typically
the principal table that the main form is based on, and the principal table
that the subform is based on, are in a one-to-many relationship to each
other. Whereas you appear to be wanting to open a secondary form,
separately to the main form, and with the same table behind both. Am I
right? So both the main form and the so-called "subform" relate to the same
record?
 
S

sg

I'm sorry I wasn't very clear on what I am doing. Let me try again, if you
would bear with me once more...

My main form (PT Test frm) is displayiing the data in datasheet view. It is
based on the PT tbl. I used the subform/subreport control to insert a
subform based on the Fail tbl. This subform is called Fail subform. The two
tables on which these forms are based are related to each other with the
field PT ID.

I know the subform is working because I am seeing the expand (+ sign) option
on the side of the form and I can expand it to enter data into the related
form (table). However, I want that subform to be shown automatically when
the combo box on the main form shows the text "Unacceptable" so the user is
reminded to enter the additional data about what is unacceptable instead of
the user having to remember to show the subform and enter information into it.

Is this a better explanation? Sorry for any confusion.
 

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