How does this work?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    How does this work?

    Following code belongs to the first field in form B. When I open form B from
    form A, ctl.Name returns the name of Form's A button which I just clicked.
    How does this work? I thought when the field got focus that would be the
    active control. How can I solve it so that it will return the name of the
    field the code is in?

    Private Sub MyFirstField_Go tFocus()

    Dim ctl As Control
    Set ctl = Screen.ActiveCo ntrol
    InfoField = ctl.Name

    End Sub

    Thanks,
    john


  • ARC

    #2
    Re: How does this work?

    In the button that opens form b, you might want to put 2 set focus commands:

    Forms!formb.set focus
    forms!formb.for m![ctrlname].setfocus



    "John" <jo@hn.comwro te in message
    news:f5hjfg$17c k$1@textnews.wa nadoo.nl...
    Following code belongs to the first field in form B. When I open form B
    from form A, ctl.Name returns the name of Form's A button which I just
    clicked. How does this work? I thought when the field got focus that would
    be the active control. How can I solve it so that it will return the name
    of the field the code is in?
    >
    Private Sub MyFirstField_Go tFocus()
    >
    Dim ctl As Control
    Set ctl = Screen.ActiveCo ntrol
    InfoField = ctl.Name
    >
    End Sub
    >
    Thanks,
    john
    >

    Comment

    • John

      #3
      Re: How does this work?

      Thanks,

      Forms!formb.set focus works fine.

      The problem now is that the name of the form is looked up in a table, so I
      have it in a string value. I tried every possible reference without luck:

      Forms!strMyStri ng.setfocus
      Forms(strMyStri ng).setfocus
      Forms![strMyString].setfocus

      What am I doing wrong???
      john



      "ARC" <andy@andyc.com schreef in bericht
      news:EoYei.2146 8$C96.4280@news svr23.news.prod igy.net...
      In the button that opens form b, you might want to put 2 set focus
      commands:
      >
      Forms!formb.set focus
      forms!formb.for m![ctrlname].setfocus
      >
      >
      >
      "John" <jo@hn.comwro te in message
      news:f5hjfg$17c k$1@textnews.wa nadoo.nl...
      >Following code belongs to the first field in form B. When I open form B
      >from form A, ctl.Name returns the name of Form's A button which I just
      >clicked. How does this work? I thought when the field got focus that
      >would be the active control. How can I solve it so that it will return
      >the name of the field the code is in?
      >>
      >Private Sub MyFirstField_Go tFocus()
      >>
      >Dim ctl As Control
      >Set ctl = Screen.ActiveCo ntrol
      >InfoField = ctl.Name
      >>
      >End Sub
      >>
      >Thanks,
      >john
      >>
      >
      >

      Comment

      • Marshall Barton

        #4
        Re: How does this work?

        John wrote:
        >Following code belongs to the first field in form B. When I open form B from
        >form A, ctl.Name returns the name of Form's A button which I just clicked.
        >How does this work? I thought when the field got focus that would be the
        >active control. How can I solve it so that it will return the name of the
        >field the code is in?
        >
        >Private Sub MyFirstField_Go tFocus()
        >
        >Dim ctl As Control
        >Set ctl = Screen.ActiveCo ntrol
        >InfoField = ctl.Name
        >
        >End Sub

        That seems a little odd, but I'd rather not trust the Screen
        object to know which form is the active form so early in the
        transition. Try using Me.ActiveContro l

        --
        Marsh

        Comment

        • ARC

          #5
          Re: How does this work?

          How about this?

          forms(strMyStri ng).Name.setfoc us






          "John" <jo@hn.comwro te in message
          news:f5hn2t$18k g$1@textnews.wa nadoo.nl...
          Thanks,
          >
          Forms!formb.set focus works fine.
          >
          The problem now is that the name of the form is looked up in a table, so I
          have it in a string value. I tried every possible reference without luck:
          >
          Forms!strMyStri ng.setfocus
          Forms(strMyStri ng).setfocus
          Forms![strMyString].setfocus
          >
          What am I doing wrong???
          john
          >
          >
          >
          "ARC" <andy@andyc.com schreef in bericht
          news:EoYei.2146 8$C96.4280@news svr23.news.prod igy.net...
          >In the button that opens form b, you might want to put 2 set focus
          >commands:
          >>
          >Forms!formb.se tfocus
          >forms!formb.fo rm![ctrlname].setfocus
          >>
          >>
          >>
          >"John" <jo@hn.comwro te in message
          >news:f5hjfg$17 ck$1@textnews.w anadoo.nl...
          >>Following code belongs to the first field in form B. When I open form B
          >>from form A, ctl.Name returns the name of Form's A button which I just
          >>clicked. How does this work? I thought when the field got focus that
          >>would be the active control. How can I solve it so that it will return
          >>the name of the field the code is in?
          >>>
          >>Private Sub MyFirstField_Go tFocus()
          >>>
          >>Dim ctl As Control
          >>Set ctl = Screen.ActiveCo ntrol
          >>InfoField = ctl.Name
          >>>
          >>End Sub
          >>>
          >>Thanks,
          >>john
          >>>
          >>
          >>
          >
          >

          Comment

          • ARC

            #6
            Re: How does this work?

            Actually, I think the last post won't work. Here's another to try:


            Forms(StrMyStri ng).Form.setfoc us



            "ARC" <andy@andyc.com wrote in message
            news:pbcfi.6861 $c06.4346@newss vr22.news.prodi gy.net...
            How about this?
            >
            forms(strMyStri ng).Name.setfoc us
            >
            >
            >
            >
            >
            >
            "John" <jo@hn.comwro te in message
            news:f5hn2t$18k g$1@textnews.wa nadoo.nl...
            >Thanks,
            >>
            >Forms!formb.se tfocus works fine.
            >>
            >The problem now is that the name of the form is looked up in a table, so
            >I have it in a string value. I tried every possible reference without
            >luck:
            >>
            >Forms!strMyStr ing.setfocus
            >Forms(strMyStr ing).setfocus
            >Forms![strMyString].setfocus
            >>
            >What am I doing wrong???
            >john
            >>
            >>
            >>
            >"ARC" <andy@andyc.com schreef in bericht
            >news:EoYei.214 68$C96.4280@new ssvr23.news.pro digy.net...
            >>In the button that opens form b, you might want to put 2 set focus
            >>commands:
            >>>
            >>Forms!formb.s etfocus
            >>forms!formb.f orm![ctrlname].setfocus
            >>>
            >>>
            >>>
            >>"John" <jo@hn.comwro te in message
            >>news:f5hjfg$1 7ck$1@textnews. wanadoo.nl...
            >>>Following code belongs to the first field in form B. When I open form B
            >>>from form A, ctl.Name returns the name of Form's A button which I just
            >>>clicked. How does this work? I thought when the field got focus that
            >>>would be the active control. How can I solve it so that it will return
            >>>the name of the field the code is in?
            >>>>
            >>>Private Sub MyFirstField_Go tFocus()
            >>>>
            >>>Dim ctl As Control
            >>>Set ctl = Screen.ActiveCo ntrol
            >>>InfoField = ctl.Name
            >>>>
            >>>End Sub
            >>>>
            >>>Thanks,
            >>>john
            >>>>
            >>>
            >>>
            >>
            >>
            >
            >

            Comment

            • John

              #7
              Re: How does this work?

              Thanks. I got it working.
              john

              "ARC" <andy@andyc.com schreef in bericht
              news:Hmcfi.6864 $c06.1830@newss vr22.news.prodi gy.net...
              Actually, I think the last post won't work. Here's another to try:
              >
              >
              Forms(StrMyStri ng).Form.setfoc us
              >
              >
              >
              "ARC" <andy@andyc.com wrote in message
              news:pbcfi.6861 $c06.4346@newss vr22.news.prodi gy.net...
              >How about this?
              >>
              >forms(strMyStr ing).Name.setfo cus
              >>
              >>
              >>
              >>
              >>
              >>
              >"John" <jo@hn.comwro te in message
              >news:f5hn2t$18 kg$1@textnews.w anadoo.nl...
              >>Thanks,
              >>>
              >>Forms!formb.s etfocus works fine.
              >>>
              >>The problem now is that the name of the form is looked up in a table, so
              >>I have it in a string value. I tried every possible reference without
              >>luck:
              >>>
              >>Forms!strMySt ring.setfocus
              >>Forms(strMySt ring).setfocus
              >>Forms![strMyString].setfocus
              >>>
              >>What am I doing wrong???
              >>john
              >>>
              >>>
              >>>
              >>"ARC" <andy@andyc.com schreef in bericht
              >>news:EoYei.21 468$C96.4280@ne wssvr23.news.pr odigy.net...
              >>>In the button that opens form b, you might want to put 2 set focus
              >>>commands:
              >>>>
              >>>Forms!formb. setfocus
              >>>forms!formb. form![ctrlname].setfocus
              >>>>
              >>>>
              >>>>
              >>>"John" <jo@hn.comwro te in message
              >>>news:f5hjfg$ 17ck$1@textnews .wanadoo.nl...
              >>>>Following code belongs to the first field in form B. When I open form
              >>>>B from form A, ctl.Name returns the name of Form's A button which I
              >>>>just clicked. How does this work? I thought when the field got focus
              >>>>that would be the active control. How can I solve it so that it will
              >>>>return the name of the field the code is in?
              >>>>>
              >>>>Private Sub MyFirstField_Go tFocus()
              >>>>>
              >>>>Dim ctl As Control
              >>>>Set ctl = Screen.ActiveCo ntrol
              >>>>InfoField = ctl.Name
              >>>>>
              >>>>End Sub
              >>>>>
              >>>>Thanks,
              >>>>john
              >>>>>
              >>>>
              >>>>
              >>>
              >>>
              >>
              >>
              >
              >

              Comment

              Working...