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

Creating a new record in a subform

Status
Not open for further replies.

jwalz

Programmer
Oct 31, 2000
78
0
0
US
Is there any way programatically to create a new record in a datasheet view sub form? I am trying to create revisions/additions to the detail items in my purchase order form, but can't figure out the correct code to make it happen.

Thanks,
Janet
 
this is very simple. from code do the following.

dim rs as dao.recordset

set rs = subformcontrol.form.recordset

with rs
.addnew
!field1 = whatever
!field2 = whatever
etc.
end with

set rs = nothing


that should be basically all you need to do. Of course you will need to change "subformcontrol" to the name of the subformcontrol on your main form, and you will need to change the field names and values assigned to them.

Let me know how this works.
 
That did the trick. Although I added a .Update to display the information that I preloaded into the fields.

Thanks so much for your excellent and speedy help.

Janet
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top