Subform problem (1 Viewer)

Emma35

Registered User.
Local time
Today, 10:21
Joined
Sep 18, 2012
Messages
455
Hi again all......in trouble as usual.
I've got a main form with a sub form attached. When i click the 'Add New Record' button in the main form, the sub form goes blank also. How can i get the sub form to remain the same (unless i decide to alter it) ??.

Ps....the info in the sub form will rarely change so i don't wan't the user to have to keep typing it in repeatedly.

Any help would be great

Cheers Em
 

Minty

AWF VIP
Local time
Today, 17:21
Joined
Jul 26, 2013
Messages
10,355
If the sub form is linked by parent / child fields then this is the expected behaviour.
The sub form is linked to the main form data - if there is no data (New record) then by definition there can't be a related linked record.

If you remove the parent child link you would have to set the subform recordsource in code based on some other change to the main forms data.
 

Emma35

Registered User.
Local time
Today, 10:21
Joined
Sep 18, 2012
Messages
455
Could i link the subform to a control on the parent form ?
 

Minty

AWF VIP
Local time
Today, 17:21
Joined
Jul 26, 2013
Messages
10,355
Could i link the subform to a control on the parent form ?
Yes you can link it anything that has the same datatype as the subform field's datatype.

So you could for instance have an unbound textbox that you update with the current main form parent ID on the main forms current event, except when Me.Newrecord = True.

This would keep the last ID's subform data until the new record is saved, or update the subform to the current already saved record.
 

Emma35

Registered User.
Local time
Today, 10:21
Joined
Sep 18, 2012
Messages
455
Thanks Minty.....i think it would be better if i just attached it so you can have a look. The form in question is frm_Add/Edit. When you press the button with the icon (middle form) it goes to a new record but the info in the sub form at the bottom goes blank

Thanks for your help
 

Attachments

  • Test - Copy.zip
    491.1 KB · Views: 34

Emma35

Registered User.
Local time
Today, 10:21
Joined
Sep 18, 2012
Messages
455
Ok managed to get to the bottom of it eventually. Thanks to everyone who had a look
 

Users who are viewing this thread

Top Bottom