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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update newly added record 1

Status
Not open for further replies.

mcollins

Programmer
Jun 16, 1999
27
0
0
US
I have a form with a datasheet subform. The subform has 2 bound fields. What I am trying to do is, when a record is added via the subform, I want to populate some additional fields of the added record (based on some unbound controls on the form). Is this possible, maybe using the After Insert event?

Thanks,
Mike
 
yes it is possible. it sounds like you already know what to do.
 
Ok, that is encouraging. But I don't know how to do it.
 
I'm not sure, but I think perhaps the after insert my perhaps fire another before update by adding stuff to the existing record. I'd try the before update event of the form, which fires whenever a save operation is performed.

Easiest would be to add the extra fields to the form recordset, i e, have them bound, also add those as controls to the form, make them hidden (can be done from datasheet view through right clicking the column header, or with me!txtControl.columnhidden=true in for instance the on open/load event of the form) - or just bind the controls you have.

Then in the before update, assign appropriate values

[tt]me!txtControl.value = "some value..."[/tt]

- or execute some sql to update them.

Roy-Vidar
 
Roy-Vidar,

This approach works fine. Thank you!

Every time I think that I need to directly access the data from a form method, it turns out that I didn't need to after all.

Thanks again!

Mike Collins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top