GoToControl on mainform from subform

T

Tim Colbourn

Dear MVP,

I am having trouble getting a macro to shift the focus on a subform back to
it’s parent form (from subform 2 (sub-subform) back to subform 1).

I have tried the following syntax:

GoToControl
F_Preg subform (name of the parent form – subform 1; btw It also doesn’t
work when I replace this with the text ‘Me.Parent’)

FindRecord
Forms!F_Preg
subform![D_HF_HSA_KI_V_W_ID]=Forms!F_MonthlyData![D_HF_HSA_KI_V_W_ID]
(this is to match the ID number of the subform (F_MonthlyData) to the parent
form (F_Preg subform); have used this after reading another posting; however
the forms are already linked by the LinkChildFields /LinkMasterfields
(underlying tables are linked with one-to-many relationship))

MsgBox
Hello
(this pops up to show that the macro has got this far without errors (when
using F_Preg subform for the first GoToControl, doesn't get this far when
using Me.Parent), however it seems that it hasn’t done the above two commands
as the focus is still on the subform and not it’s parent)

GoToControl
Me.Parent!PregOutcomeMisAb
(this is the name of the control on the parent form that I want to the focus
to shift to; I have tried naming it just by it’s field name
(PregOutcomeMisAb) given that the focus should have already shifted to the
parent form, but this doesn’t work as I think it ignores the command to go to
the parent form (see above); I have also tried calling it
Forms!F_MonthlyData!PregOutcomeMisAb –it’s full name; but this also
doesn’work; for all ways of naming I get the message:

‘There is no field named ‘whatever name I use’ in the current record’

I have copied and pasted the name from the name field in the properties box
to ensure it is spelt correctly and indeed just after the error message
appears I can see in the properties box that the field I want to go to does
exist!

(Please note that the forms are set to Data Entry : No, and everything else,
edits / additions etc, are allowed; I have also tried it with Data Entry =
Yes and it doesn’t work; also the field I want the focus to go to is visible
and enabled and I can go there after the macro fails by clicking it or by
pressing Ctrl+TAB;
Other information that may be useful to you is that the parent and child
forms are linked by the LinkChildFields / LinkMasterFields properties and
this is working fine and the relationships between the tables that the forms
are based on (one-to many) are also fine;
The macro is linked to the AfterUpdate property of the field in the subform
from which I want to move to the mainform from)

This is very annoying, can you help please?

Tim
 

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