Synchronization problem openform bookmark

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?
 
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?

Problem solved

the following code inserted between line 1 and 2 did it all
With Forms(strForm)
.SetFocus
.Recalc
.Repaint
End With

Thank you for all help Allen

Mats
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top