GoToControl on mainform from subform

T

Tim Colbourn

Dear MVP,

I posted this on the 'forms coding' page on 30th Oct and still haven't got a
reply so I thought i'd post it here...

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 (after consulting
http://www.mvps.org/access/forms/frm0031.htm):

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
 
D

Douglas J. Steele

Don't use GoToControl: it only works for the active form.

Instead, use

Me.Parent!PregOutcomeMisAb.SetFocus

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Tim Colbourn said:
Dear MVP,

I posted this on the 'forms coding' page on 30th Oct and still haven't got
a
reply so I thought i'd post it here...

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 (after consulting
http://www.mvps.org/access/forms/frm0031.htm):

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
 
T

Tim Colbourn

Hi Doug,

Thanks for getting back to me. However my problem has not been solved.

I'm not sure where I should be writing the

Me.Parent!PregOutcomeMisAb.SetFocus

I am using a macro (as I don't know Visual Basic) and 'Set Focus' is not one
of the macro actions available. Therefore I have tried writing
Me.Parent!PregOutcomeMisAb.SetFocus
in the 'Set Value' action (in the 'Item' box at the bottom, like I have done
for ControlName.Enabled or ControlName.Visible with success) however if I
leave the 'Expression' box blank nothing happens and if I write 'Yes' in the
'Expression' box the macro doesn't work citing the following error:

"The object doesn’t contain the automation object ‘Me.’
You tried to run a Visual Basic procedure to set a property or method for an
object. However, the component doesn’t make the property or method available
for Automation operations.
Check the component’s documentation for information on the properties and
methods it makes available for Automation operations."

With regard to this message it is a macro and not directly in VB (although I
guess the macro runs a VB code automatically). As regards availability for
automation operations I'm not sure what this refers to but everything is
enabled and visible an unlocked. It seems that it can't find Me or the parent
form or anything...

Please advise in detail (I realise this discussion is hampered by the fact
you are 9hrs behind me (I am in Malawi) so we are always delayed by at least
a day, and I am running very tight for time to get this thing working)

Cheers,

Tim

Douglas J. Steele said:
Don't use GoToControl: it only works for the active form.

Instead, use

Me.Parent!PregOutcomeMisAb.SetFocus

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Tim Colbourn said:
Dear MVP,

I posted this on the 'forms coding' page on 30th Oct and still haven't got
a
reply so I thought i'd post it here...

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 (after consulting
http://www.mvps.org/access/forms/frm0031.htm):

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
 
D

Douglas J. Steele

I think you may have to bite the bullet, and use VBA.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Tim Colbourn said:
Hi Doug,

Thanks for getting back to me. However my problem has not been solved.

I'm not sure where I should be writing the

Me.Parent!PregOutcomeMisAb.SetFocus

I am using a macro (as I don't know Visual Basic) and 'Set Focus' is not
one
of the macro actions available. Therefore I have tried writing
Me.Parent!PregOutcomeMisAb.SetFocus
in the 'Set Value' action (in the 'Item' box at the bottom, like I have
done
for ControlName.Enabled or ControlName.Visible with success) however if I
leave the 'Expression' box blank nothing happens and if I write 'Yes' in
the
'Expression' box the macro doesn't work citing the following error:

"The object doesn't contain the automation object 'Me.'
You tried to run a Visual Basic procedure to set a property or method for
an
object. However, the component doesn't make the property or method
available
for Automation operations.
Check the component's documentation for information on the properties and
methods it makes available for Automation operations."

With regard to this message it is a macro and not directly in VB (although
I
guess the macro runs a VB code automatically). As regards availability
for
automation operations I'm not sure what this refers to but everything is
enabled and visible an unlocked. It seems that it can't find Me or the
parent
form or anything...

Please advise in detail (I realise this discussion is hampered by the fact
you are 9hrs behind me (I am in Malawi) so we are always delayed by at
least
a day, and I am running very tight for time to get this thing working)

Cheers,

Tim

Douglas J. Steele said:
Don't use GoToControl: it only works for the active form.

Instead, use

Me.Parent!PregOutcomeMisAb.SetFocus

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Tim Colbourn said:
Dear MVP,

I posted this on the 'forms coding' page on 30th Oct and still haven't
got
a
reply so I thought i'd post it here...

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 (after consulting
http://www.mvps.org/access/forms/frm0031.htm):

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
 
T

Tim Colbourn

Not sure if I have enough time to learn VBA right now! (have short deadline)
so would it be possible for you to write me a short code for this Set Focus
procedure, saying where I would put Conditions (e.g. if a specific value is
entered in the field) for the Set Focus and including all beginning and end
bits of the code so that it is self contained and works properly?

Thanks very much,

Tim

Douglas J. Steele said:
I think you may have to bite the bullet, and use VBA.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Tim Colbourn said:
Hi Doug,

Thanks for getting back to me. However my problem has not been solved.

I'm not sure where I should be writing the

Me.Parent!PregOutcomeMisAb.SetFocus

I am using a macro (as I don't know Visual Basic) and 'Set Focus' is not
one
of the macro actions available. Therefore I have tried writing
Me.Parent!PregOutcomeMisAb.SetFocus
in the 'Set Value' action (in the 'Item' box at the bottom, like I have
done
for ControlName.Enabled or ControlName.Visible with success) however if I
leave the 'Expression' box blank nothing happens and if I write 'Yes' in
the
'Expression' box the macro doesn't work citing the following error:

"The object doesn't contain the automation object 'Me.'
You tried to run a Visual Basic procedure to set a property or method for
an
object. However, the component doesn't make the property or method
available
for Automation operations.
Check the component's documentation for information on the properties and
methods it makes available for Automation operations."

With regard to this message it is a macro and not directly in VB (although
I
guess the macro runs a VB code automatically). As regards availability
for
automation operations I'm not sure what this refers to but everything is
enabled and visible an unlocked. It seems that it can't find Me or the
parent
form or anything...

Please advise in detail (I realise this discussion is hampered by the fact
you are 9hrs behind me (I am in Malawi) so we are always delayed by at
least
a day, and I am running very tight for time to get this thing working)

Cheers,

Tim

Douglas J. Steele said:
Don't use GoToControl: it only works for the active form.

Instead, use

Me.Parent!PregOutcomeMisAb.SetFocus

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dear MVP,

I posted this on the 'forms coding' page on 30th Oct and still haven't
got
a
reply so I thought i'd post it here...

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 (after consulting
http://www.mvps.org/access/forms/frm0031.htm):

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
 
D

Douglas J. Steele

What exactly do you need the sub to do?

You say that this is to be in the AfterUpdate event of a text box. Select
the text box while the form's open in Design view and go to the Properties
window. Find the After Update event property, select [Event Procedure] for
its value, then click on the ellipsis (...) to the right of the property.
That'll take you into the VB Editor, in the midst of code that looks like:

Private Sub NameOfTextbox_AfterUpdate()

End Sub

To check that value of the text box, you'd add something like

If Me.NameOfTextbox = "Some value" Then

Else

End If

If you only want the focus to move when the text box contains the given
value, you'd put the Me.Parent!PregOutcomeMisAb.SetFocus in the "If" leg (as
opposed to the "Else" leg), so that your complete procedure would look like:

Private Sub NameOfTextbox_AfterUpdate()

If Me.NameOfTextbox = "Some value" Then
Me.Parent!PregOutcomeMisAb.SetFocus
End If

End Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Tim Colbourn said:
Not sure if I have enough time to learn VBA right now! (have short
deadline)
so would it be possible for you to write me a short code for this Set
Focus
procedure, saying where I would put Conditions (e.g. if a specific value
is
entered in the field) for the Set Focus and including all beginning and
end
bits of the code so that it is self contained and works properly?

Thanks very much,

Tim

Douglas J. Steele said:
I think you may have to bite the bullet, and use VBA.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Tim Colbourn said:
Hi Doug,

Thanks for getting back to me. However my problem has not been solved.

I'm not sure where I should be writing the

Me.Parent!PregOutcomeMisAb.SetFocus

I am using a macro (as I don't know Visual Basic) and 'Set Focus' is
not
one
of the macro actions available. Therefore I have tried writing
Me.Parent!PregOutcomeMisAb.SetFocus
in the 'Set Value' action (in the 'Item' box at the bottom, like I have
done
for ControlName.Enabled or ControlName.Visible with success) however if
I
leave the 'Expression' box blank nothing happens and if I write 'Yes'
in
the
'Expression' box the macro doesn't work citing the following error:

"The object doesn't contain the automation object 'Me.'
You tried to run a Visual Basic procedure to set a property or method
for
an
object. However, the component doesn't make the property or method
available
for Automation operations.
Check the component's documentation for information on the properties
and
methods it makes available for Automation operations."

With regard to this message it is a macro and not directly in VB
(although
I
guess the macro runs a VB code automatically). As regards availability
for
automation operations I'm not sure what this refers to but everything
is
enabled and visible an unlocked. It seems that it can't find Me or the
parent
form or anything...

Please advise in detail (I realise this discussion is hampered by the
fact
you are 9hrs behind me (I am in Malawi) so we are always delayed by at
least
a day, and I am running very tight for time to get this thing working)

Cheers,

Tim

:

Don't use GoToControl: it only works for the active form.

Instead, use

Me.Parent!PregOutcomeMisAb.SetFocus

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Dear MVP,

I posted this on the 'forms coding' page on 30th Oct and still
haven't
got
a
reply so I thought i'd post it here...

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 (after consulting
http://www.mvps.org/access/forms/frm0031.htm):

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
 
T

Tim Colbourn

Thanks Doug that code works fine. Maybe VB isn't so daunting after all...

Douglas J. Steele said:
What exactly do you need the sub to do?

You say that this is to be in the AfterUpdate event of a text box. Select
the text box while the form's open in Design view and go to the Properties
window. Find the After Update event property, select [Event Procedure] for
its value, then click on the ellipsis (...) to the right of the property.
That'll take you into the VB Editor, in the midst of code that looks like:

Private Sub NameOfTextbox_AfterUpdate()

End Sub

To check that value of the text box, you'd add something like

If Me.NameOfTextbox = "Some value" Then

Else

End If

If you only want the focus to move when the text box contains the given
value, you'd put the Me.Parent!PregOutcomeMisAb.SetFocus in the "If" leg (as
opposed to the "Else" leg), so that your complete procedure would look like:

Private Sub NameOfTextbox_AfterUpdate()

If Me.NameOfTextbox = "Some value" Then
Me.Parent!PregOutcomeMisAb.SetFocus
End If

End Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Tim Colbourn said:
Not sure if I have enough time to learn VBA right now! (have short
deadline)
so would it be possible for you to write me a short code for this Set
Focus
procedure, saying where I would put Conditions (e.g. if a specific value
is
entered in the field) for the Set Focus and including all beginning and
end
bits of the code so that it is self contained and works properly?

Thanks very much,

Tim

Douglas J. Steele said:
I think you may have to bite the bullet, and use VBA.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi Doug,

Thanks for getting back to me. However my problem has not been solved.

I'm not sure where I should be writing the

Me.Parent!PregOutcomeMisAb.SetFocus

I am using a macro (as I don't know Visual Basic) and 'Set Focus' is
not
one
of the macro actions available. Therefore I have tried writing
Me.Parent!PregOutcomeMisAb.SetFocus
in the 'Set Value' action (in the 'Item' box at the bottom, like I have
done
for ControlName.Enabled or ControlName.Visible with success) however if
I
leave the 'Expression' box blank nothing happens and if I write 'Yes'
in
the
'Expression' box the macro doesn't work citing the following error:

"The object doesn't contain the automation object 'Me.'
You tried to run a Visual Basic procedure to set a property or method
for
an
object. However, the component doesn't make the property or method
available
for Automation operations.
Check the component's documentation for information on the properties
and
methods it makes available for Automation operations."

With regard to this message it is a macro and not directly in VB
(although
I
guess the macro runs a VB code automatically). As regards availability
for
automation operations I'm not sure what this refers to but everything
is
enabled and visible an unlocked. It seems that it can't find Me or the
parent
form or anything...

Please advise in detail (I realise this discussion is hampered by the
fact
you are 9hrs behind me (I am in Malawi) so we are always delayed by at
least
a day, and I am running very tight for time to get this thing working)

Cheers,

Tim

:

Don't use GoToControl: it only works for the active form.

Instead, use

Me.Parent!PregOutcomeMisAb.SetFocus

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Dear MVP,

I posted this on the 'forms coding' page on 30th Oct and still
haven't
got
a
reply so I thought i'd post it here...

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 (after consulting
http://www.mvps.org/access/forms/frm0031.htm):

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