A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Adding recs from subforms



 
 
Thread Tools Display Modes
  #1  
Old June 14th, 2004, 06:15 AM
TracyG
external usenet poster
 
Posts: n/a
Default Adding recs from subforms

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.


  #2  
Old June 14th, 2004, 06:50 PM
John Vinson
external usenet poster
 
Posts: n/a
Default Adding recs from subforms

On Mon, 14 Jun 2004 00:15:50 -0500, "TracyG"
wrote:

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.


John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
  #3  
Old June 14th, 2004, 06:51 PM
dandgard
external usenet poster
 
Posts: n/a
Default Adding recs from subforms


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.


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.