Add new record to a form form another form

suepowell

Registered User.
Local time
Today, 21:55
Joined
Mar 25, 2003
Messages
282
HI,

Is there any way to add a new record to a form from another pop up form.

I have a pop up form the is opened from another subform which lists all the parts from a particular supplier. When I click a button I add the partnumber to the partnumber field of the original subform.

What I want to be able to do is instruct the subform to move to a new record so I can make more selections form the pop up form.

I know I could do this using recordsets into the underlying table, but I have lots of code that runs when a new partnumber is selected and don't want to have to redo this code somewhere else.

I have tried the following code
[Forms]![frmPurchaseOrders]![subPurchaseOrdersDetails].[Form]![PartNumber] = Me.PartNumber
DoCmd.GoToRecord acDataForm, "subPurchaseOrdersDetails", acNewRec

the fiorst line works and all of the required code runs, but the second line fails with the error "the object subpurchaseordersdetails isn't open", which a plainly not true as I have just sucessfully written to it and can see the result.

Does anyone know if this is possible, and what I am missing.

Thanks

Sue
 
Maybe you need to refer to the actual subform:


[Forms]![frmPurchaseOrders]![subPurchaseOrdersDetails].[Form]![PartNumber] = Me.PartNumber
DoCmd.GoToRecord acDataForm, "[Forms]![frmPurchaseOrders]!subPurchaseOrdersDetails.Form", acNewRec




???
 
HI Ken,

Thanks for the reply.

I have just tried that but get the same result.

I can set focus to a field on that form, does set focus let you specfy a field on a new record, I'll try and find out.

Thanks

Sue
 
I bet Bob can spot what we're doing wrong - May he'll pop in and take a shot...
 
I bet Bob can spot what we're doing wrong - May he'll pop in and take a shot...

Sure, here you go:
Code:
Forms!frmPurchaseOrders!subPurchaseOrdersDetails.Form.Recordset.AddNew
 
Thank you so much, you've just saved me hours of frustration and programming!

I can go home happy now, at least I can when it stops raining, I didn't bring a coat today and it's the sort of storm that drills straight through you!

Thanks Again.

Sue
 

Users who are viewing this thread

Back
Top Bottom