I want to know if I'm in a specific field on a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CD Tom
    Contributor
    • Feb 2009
    • 495

    #1

    I want to know if I'm in a specific field on a form

    I'm using the Calendar (ocxcalendar). I have five calendar fields on my form and I would like to use just one calendar and put an If statement as to what field I'm in. How do I do this? This is probably very simple but for the life of me I don't seem to be able to make it work.

    Thanks for any help.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    I use one that's a derivation of one that I inherited. The original call to the code passes the control as a parameter which is stored locally in the form.

    It's a roll-your-own one using a simple Form.

    Comment

    • jforbes
      Recognized Expert Top Contributor
      • Aug 2014
      • 1107

      #3
      I'm not quite sure what you are asking about. If you want to get the name of the control that currently has focus, you can use:
      Code:
      Screen.ActiveControl.Name
      or for the previous control:
      Code:
      Screen.PreviousControl.Name

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        I considered posting something on those lines, JForbes, but couldn't see how the control referred to could be the active control as the calendar control would be. That said, I guess Tom must have got something from that as he's flagged it as the best answer.

        Maybe the PreviousControl is what he likes it for. I don't know that object well enough to know if that can be guaranteed to be the one that triggered the calendar but it certainly would be in most cases. If not then passing a reference in the call might still make the most sense.

        Comment

        • CD Tom
          Contributor
          • Feb 2009
          • 495

          #5
          I was able to use the previouscontrol and it worked just like I wanted it to. Thanks for all the help

          Comment

          • jforbes
            Recognized Expert Top Contributor
            • Aug 2014
            • 1107

            #6
            Glad you got it working. I just took a stab at it.

            I've never used the Calendar control. I've looked at it, but it didn't thrill me enough to move away from the .ShowDatePicker property built into the TextBox control.

            Comment

            • CD Tom
              Contributor
              • Feb 2009
              • 495

              #7
              I would be interested in ShowDatePicker as I'm having problems with the calendar when I try and compile the program using Access 2016 64bit version. I have a couple of users that have purchased the office 365 in 64bit and because they are using it with another database they have a problem switching between the two. When in my database it installs the runtime and then when they go back to their other version it tries to reinstall the 64bit version and they have to load it.
              If you are anyone has had problems switching I would be interested in any help. I get type mismatch errors when compiling also.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32669

                #8
                It's a minefield Tom. Be very careful.

                That said, there is help out there. You may struggle finding all the relevant stuff though.

                Good luck anyway :-)

                Comment

                Working...