Adding recs from subforms

  • Thread starter Thread starter TracyG
  • Start date Start date
T

TracyG

Hi all - I need help with subforms. I have a main form with multiple
subforms *eek!*. In each of these subforms I need to allow records to be
added to the associated tables. There is a single key that links the main
form to each subform. I am storing the key on the form in a text box but
have the property set as visible=false.

when I attempt to add a record to the sub forms, I get an error message that
says the "field is too small to accept the amount of data you ttempted to
add. Try inserting or pasting less"... however, the fields are over 15
characters and it happens after typing the first character.

First I need to get past the error message THEN I need to be able to update
the new record with the key value prior to the record being stored to avoid
attempting to add a null value on a key field.

Does anyone know what is causing the error?

also - Which event would I use to put the appropriate key value into the new
record? I tried before insert, after insert, ... several events to no
avail.
 
Hi all - I need help with subforms. I have a main form with multiple
subforms *eek!*. In each of these subforms I need to allow records to be
added to the associated tables. There is a single key that links the main
form to each subform. I am storing the key on the form in a text box but
have the property set as visible=false.

when I attempt to add a record to the sub forms, I get an error message that
says the "field is too small to accept the amount of data you ttempted to
add. Try inserting or pasting less"... however, the fields are over 15
characters and it happens after typing the first character.

Do you have any LOOKUP fields in your tables? If so, this may well be
the problem. What you *see* in a table lookup field is the 15 byte
text (or whatever it might be) - but that is *NOT* what is stored in
the table. What's stored is a numeric ID, concealed from your view by
Microsoft's misdesigned, misleading, obnoxious Lookup misfeature. See

http://www.mvps.org/access/lookupfields.htm

for a critique.
First I need to get past the error message THEN I need to be able to update
the new record with the key value prior to the record being stored to avoid
attempting to add a null value on a key field.

Does anyone know what is causing the error?

also - Which event would I use to put the appropriate key value into the new
record? I tried before insert, after insert, ... several events to no
avail.

Ummm... if you're using a Subform (rather than popping up a form in
code), simply set the Subform control's Master Link Field to the main
form's Primary Key field and the Child Link Field to the name of the
linking field in the subform's table; you don't need a control on
either form nor do you need any VBA code at all.
 
If you have the form and subform linked by the key field then you
shouldn't have to use an event to fill the key field, it should be done
for you automatically.

Make sure that you have fields (visible or not) for the key field on
both the form and subform and that they are linked through the subform
control on the main form. When you dirty a record on the subform the
key field should be filled in.

(Also the key fields on the form must be associated with the actual
field in the underlying table for the form and subform).

Your error indicates that a field in the table will not accept the
number of characters you are trying to enter. Make sure that the key
fields that connect your tables are of the same length.
 
Back
Top