M
mabl123456
I have a main form with two subforms (cf customer - order -
orderline). The first subform (order) is linked to the main form
normally via linkchildfields and linkmasterfields set to primary key
in mainform. On the mainform I have a control which mirrors the
primary key from subform 1. Subform 2 is linked to subform 1 via the
control in main form and a subform2.requery on subform1 oncurrent
event.
I open the main form programatically with
1 DoCmd.OpenForm strForm
and then change to a specific record with
2 Forms(strForm).RecordsetClone.FindFirst CStr(strIdField) & " = " &
varIDControl
3 If Not Forms(strForm).RecordsetClone.NoMatch Then
4 Forms(strForm).Bookmark = Forms(strForm).RecordsetClone.Bookmark
5 End If
If main form is open when this code runs everything works fine. BUT
if
main form is closed there will be no records i subform 2 after the
code has completed. If I step through code there is records in
subform
2 after line 1 but they disappear at line 4 (when oncurrent event in
subform 1 fires).
Can anyone give me a workaround or explain this to me?
orderline). The first subform (order) is linked to the main form
normally via linkchildfields and linkmasterfields set to primary key
in mainform. On the mainform I have a control which mirrors the
primary key from subform 1. Subform 2 is linked to subform 1 via the
control in main form and a subform2.requery on subform1 oncurrent
event.
I open the main form programatically with
1 DoCmd.OpenForm strForm
and then change to a specific record with
2 Forms(strForm).RecordsetClone.FindFirst CStr(strIdField) & " = " &
varIDControl
3 If Not Forms(strForm).RecordsetClone.NoMatch Then
4 Forms(strForm).Bookmark = Forms(strForm).RecordsetClone.Bookmark
5 End If
If main form is open when this code runs everything works fine. BUT
if
main form is closed there will be no records i subform 2 after the
code has completed. If I step through code there is records in
subform
2 after line 1 but they disappear at line 4 (when oncurrent event in
subform 1 fires).
Can anyone give me a workaround or explain this to me?