Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a second record

Status
Not open for further replies.

loneranger27

Programmer
Apr 22, 2003
94
US
Hi,

I have a form and a subform. The user enters record data in to the main form then a summary of it apprears on the subform, this works fine. But when I try to add a second record to the main form via a add record button I get an error you tried to assign the null value to a variable field that is not a variant datat type. The field is the foreign key field that is set from an autonumber field on the before insert of the main form event.
Me![appid]=forms![fieldinfo]![appid]. When I press the debug button that is the statement that it takes me too.

I would appreciate any ideas anyone might have.
Thanks
 
If you have the button on the main form, that is exactly what happens with the BeforeInsert event.

BeforeInserting a record, the field value is Null.
Me![AppId]=whatever is trying to write data, but Jet sees it's a numeric value and prevents the null from being written.

If the field is AutoNumber, you don't need to do anything...it's auto assigned.

However, you should requery the subform in the AfterInsert (or even better, the AfterUpdate) event of the main form.

HTH



[pipe]
Daniel Vlas
Systems Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top