Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2003
    Posts
    280

    Unanswered: how to determine if a specific textbox has the focus?

    I'm trying to send a date to a specific textbox when it has the focus. There will be two textbox on the form for a date(date from and date to) that is using the same Calendar Control Form. Is there a way to determine it with VBScript?

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    well, i don't do it your way, but i do use only one calendar control to handle any number of forms with textboxes expecting dates.

    my calendar control lives in it's own form and pops up when the user attempts to attack a date-expecting text box anywhere in the application.

    the game plan is to pass the text control (and it's initial value) to the calendar-form as it opens rather than looking for the calling textbox afterwards. it does require a rather ugly calling convention but it is very robust and handles all calendar issues for me.

    have a look at this.

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Apr 2003
    Posts
    280
    yes, I also create a separate form for the Calender Control. Your code was complicated but I saw one of your variable type and it gives me an idea on creating a simplier code that's work for every active form.

    Private Sub Calendar_Click()

    Dim frmCurrentForm As Form
    Dim TargetTextBox As TextBox

    'Hide form, so be able to get the form name of the active form
    Form_frmCalender.Visible = False

    Set frmCurrentForm = Screen.ActiveForm
    Set TargetTextBox = frmCurrentForm.ActiveControl

    'Send date to the textbox that has the cursor for the active form
    TargetTextBox = Calendar.Value
    DoCmd.Close acForm, "Form_frmCalender"

    End Sub
    Last edited by lansing; 12-30-04 at 12:53.

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    your .activecontrol is an interesting variation!!
    i shall have to think some more when i have recovered from last night's champagne.

    i don't only want to enter dates, i also want to edit existing dates (depending on the application my popup can have many other controls (e.g. +30 +60 +90 days, Month-End, Quarter-end, FY-end etc etc etc)
    how do you plan to pass the starting value of the textbox?
    ?? again with a hide/read/unhide, ?? openargs (i hate them, but exceptions happen), ?? or ??

    the upside of my clunky calling syntax is that i can set TargetTextBox, initial value, and popup caption so the users can't forget which date they are playing with (...in one app i have 18 date fields on one subform so the user can get lost without that caption!).
    .tag should solve the missing caption!

    you might just tempt me to change the standard utility i have been using for five years!!!!

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    lansing,

    it is no-brain to capture the source control (and it's .value & .tag) with the Form_Open()

    i am so pleased with this improvement i will post a demo in Teddy's utility thread


    thanks for the inspiration!!!!


    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Apr 2003
    Posts
    280
    Quote Originally Posted by izyrider
    lansing,

    it is no-brain to capture the source control (and it's .value & .tag) with the Form_Open()

    i am so pleased with this improvement i will post a demo in Teddy's utility thread


    thanks for the inspiration!!!!


    izy
    Your welcome. You have help me in the past as well, I thank you as well.

    btw, why so many date field for just one form? I'm just curious because I may be able to help you to simplify it.
    Last edited by lansing; 01-05-05 at 10:47.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •