PC Review


Reply
Thread Tools Rate Thread

Adding a record to a subform with a macro

 
 
sg
Guest
Posts: n/a
 
      29th Mar 2010
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.
 
Reply With Quote
 
 
 
 
Steve Schapel
Guest
Posts: n/a
 
      29th Mar 2010
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?

--
Steve Schapel, Microsoft Access MVP


"sg" <(E-Mail Removed)> wrote in message
news:837096D2-D01D-46F2-8667-(E-Mail Removed)...
> 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.


 
Reply With Quote
 
sg
Guest
Posts: n/a
 
      29th Mar 2010
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.

"Steve Schapel" wrote:

> 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?
>
> --
> Steve Schapel, Microsoft Access MVP
>
>
> "sg" <(E-Mail Removed)> wrote in message
> news:837096D2-D01D-46F2-8667-(E-Mail Removed)...
> > 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.

>
> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding a new record at subform should update an existing record (not create new record) Mark Kubicki Microsoft Access Form Coding 1 16th Jan 2009 08:34 AM
How does one protect against subform adding record before main form has record? Chips Microsoft Access Forms 3 2nd May 2004 04:19 PM
Re: adding new record in subform John Vinson Microsoft Access Getting Started 3 8th Oct 2003 02:55 PM
form / subform - problem adding new record! - can't save main record Bob Microsoft Access Forms 2 7th Oct 2003 06:19 PM
Stop adding record in subform after record count = 1 Charlie Microsoft Access Forms 0 31st Jul 2003 11:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:15 AM.