Home All Groups Group Topic Archive Search About

Syntax to refer to a control on a subform.

Author
24 Feb 2005 8:59 AM
Timboo
Hi, I have (below) some code that opens a form(FrmRecUpdate) based on the
selected PatientNo in another form called FrmClinic1sub. 

'DoCmd.OpenForm "FrmRecUpdate", , , "[PatientNo] =
Forms![FrmClinic1Sub]![PatientNo]"

This works fine when the form FrmClinic1Sub is opened as a standalone form.
However it needs to open as a Subform, contained within a form called
FrmClinic1. When I amend the code to account for the fact that FrmClinic1Sub
is now a subform, it fails.  My new code is partly derived from the help
screen, and from the original code, suggested by Rowiga

DoCmd.OpenForm "FrmRecUpdate", , , "PatientNo =
Forms!FrmClinic1.FrmClinic1sub.Form!Controls.PatientNo"

Am I making a mistake, or is this action not possible from a subfrom?

Thank you, Tim

Author
24 Feb 2005 8:55 PM
Van T. Dinh
It is possible.

If the code is in the context of FrmClinic1Sub and [PatientNo] is a numeric
Field or a Control bound to a numeric Field, use:

DoCmd.OpenForm "FrmRecUpdate", , , "[PatientNo] = " & Me.[PatientNo]

--
HTH
Van T. Dinh
MVP (Access)




Show quote
"Timboo" <Tim***@discussions.microsoft.com> wrote in message
news:30453341-C648-4516-9F35-A5B3798CB7D4@microsoft.com...
> Hi, I have (below) some code that opens a form(FrmRecUpdate) based on the
> selected PatientNo in another form called FrmClinic1sub.
>
> 'DoCmd.OpenForm "FrmRecUpdate", , , "[PatientNo] =
> Forms![FrmClinic1Sub]![PatientNo]"
>
> This works fine when the form FrmClinic1Sub is opened as a standalone
form.
> However it needs to open as a Subform, contained within a form called
> FrmClinic1. When I amend the code to account for the fact that
FrmClinic1Sub
> is now a subform, it fails.  My new code is partly derived from the help
> screen, and from the original code, suggested by Rowiga
>
> DoCmd.OpenForm "FrmRecUpdate", , , "PatientNo =
> Forms!FrmClinic1.FrmClinic1sub.Form!Controls.PatientNo"
>
> Am I making a mistake, or is this action not possible from a subfrom?
>
> Thank you, Tim
>
>
>
>
>
Author
28 Feb 2005 8:17 AM
Timboo
Van T.

Thank you, will try this later today, and thank you for your other post too.
Does the code below only work on numerical fields, as the PatientNo is
actually text, since the patient number, although a number also has the first
initials of the hospital infront.

Thank you Tim.


Show quote
"Van T. Dinh" wrote:

> It is possible.
>
> If the code is in the context of FrmClinic1Sub and [PatientNo] is a numeric
> Field or a Control bound to a numeric Field, use:
>
> DoCmd.OpenForm "FrmRecUpdate", , , "[PatientNo] = " & Me.[PatientNo]
>
> --
> HTH
> Van T. Dinh
> MVP (Access)
>
>
>
>
> "Timboo" <Tim***@discussions.microsoft.com> wrote in message
> news:30453341-C648-4516-9F35-A5B3798CB7D4@microsoft.com...
> > Hi, I have (below) some code that opens a form(FrmRecUpdate) based on the
> > selected PatientNo in another form called FrmClinic1sub.
> >
> > 'DoCmd.OpenForm "FrmRecUpdate", , , "[PatientNo] =
> > Forms![FrmClinic1Sub]![PatientNo]"
> >
> > This works fine when the form FrmClinic1Sub is opened as a standalone
> form.
> > However it needs to open as a Subform, contained within a form called
> > FrmClinic1. When I amend the code to account for the fact that
> FrmClinic1Sub
> > is now a subform, it fails.  My new code is partly derived from the help
> > screen, and from the original code, suggested by Rowiga
> >
> > DoCmd.OpenForm "FrmRecUpdate", , , "PatientNo =
> > Forms!FrmClinic1.FrmClinic1sub.Form!Controls.PatientNo"
> >
> > Am I making a mistake, or is this action not possible from a subfrom?
> >
> > Thank you, Tim
> >
> >
> >
> >
> >
>
>
>
Author
28 Feb 2005 11:00 AM
Van T. Dinh
If it is Text, you need to use:

    DoCmd.OpenForm "FrmRecUpdate", , , _
        "[PatientNo] = '" & Me.[PatientNo] & "'"



--
HTH
Van T. Dinh
MVP (Access)


Show quote
"Timboo" <Tim***@discussions.microsoft.com> wrote in message
news:BB852BE1-D357-46A6-BA41-0EFE10E9BE2E@microsoft.com...
> Van T.
>
> Thank you, will try this later today, and thank you for your other post
too.
>  Does the code below only work on numerical fields, as the PatientNo is
> actually text, since the patient number, although a number also has the
first
> initials of the hospital infront.
>
> Thank you Tim.
>
>

AddThis Social Bookmark Button