RE: New Records not created in a nested form having subforms
- From: Klatuu <Klatuu@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 21 Dec 2007 06:47:01 -0800
The way to relate records in the subform the the parent records in the main
form is to use the Link Master Fields and Link Child Fields of the subform
control on the main form. You enter the name of the field or fields in the
parent record the relate to the child record in the Link Master Fields
property and the name of the field or fields in the child record that relate
to the parent record. This keeps the two in sync so that when you change
records in the main form, the related records show in the sub form.
As to not being able to add records, there are a couple of things. It is
possible when using a query as a record source that has more than one table
to create an uneditable recordset. If this is not the case, there are
properties in the form that determine whether you can add, delete, or edit.
Check those. If neither of those resolve the problem, post back with more
detail and let's see what might be causing the problem.
--
Dave Hargis, Microsoft Access MVP
"raylopez99" wrote:
This apparently is a common problem, but I can't quite grasp the.
solution. In creating a form and subform (nested relationship), I
foolishly tried (being a beginner in Access forms, though I do have
some newbie experience coding in C# for dBs and know how to write a
SQL query, set up tables, etc) to access data from a outside table
from the subform nested inside the parent form. This apparently is
frowned upon by the default settings (I'm sure you can do it if you
code in Visual Basic the "OnLoad" property of the form perhaps).
I tried running a query that accessed the outside table, and this did
work in getting rid of the error messages, but now the form is "no new
records allowed" and will not allow new records to be created (you can
only edit existing records). BTW the offending data field in the
outside table is a primary key, if that matters.
Several questions.
First, in a subform, how do you access records from the parent (other
than writing a SQL query) in the Properties tab of the RecordSource of
the form (found in the upper left square of the form)? The parent,
not an external table (if that matters). Just curious. Do you have
to do an [Event Procedure] in the "OnLoad" event for the form or
subform? I say "other than writing a SQL query" because apparently (if
you read the below post after my signature) a SQL query is not
updatable, and is a sort of virtual table that presumeably will not
allow you to write a new record in any table queried by the query.
Second, and perhaps related, how can I quickly fix this problem and be
able to add New Records? I did get rid of the offending external
field, but still the database is "no new records"--how to solve this
without learning Visual Basic (I know C++, C# and a bit of Java, but
don't want to learn VB unless I have to--this is a one time Access dB
solution).
Thank you
RL
PS--I did check that "Data Entry" property was set to "yes" and "Allow
Additions" was set to "yes", but what's funny is that another "wizard
created" form/sub-form has these properties set to "no" and it works
fine, so these properties are not important in this particular problem
From another post a few years ago...
[USER HAVING PROBLEM CREATING NEW RECORDS IN A FORM THAT HAS
SUBFORMS...]
I have ensured that the properties of the form allow
addition of new records, and that all required fields
contain data.
Any ideas?
Thanks,
Todd
Nikos Yannacopoulos View profile
More options Mar 12 2004, 3:06 am
Todd,
Just guessing here... is your form's recordsource a query? If so, does
the
query contain several tables? If that's the case then chances are the
recordset (returned by the query...) is not updatable. To verify open
the
query in datasheet view and try to change or add a record, to see if
it lets
you do it.
If this is indeed the problem, then the reason why you get no error
message
is probably a SetWarnings action in a query / method in code.
HTH,
Nikos
- Follow-Ups:
- Re: New Records not created in a nested form having subforms
- From: raylopez99
- Re: New Records not created in a nested form having subforms
- References:
- New Records not created in a nested form having subforms
- From: raylopez99
- New Records not created in a nested form having subforms
- Prev by Date: Re: Invalid use of Null
- Next by Date: Re: cumulative percentage
- Previous by thread: New Records not created in a nested form having subforms
- Next by thread: Re: New Records not created in a nested form having subforms
- Index(es):
Relevant Pages
|