Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2002
    Location
    Independence, Kansas
    Posts
    22

    Unhappy Unanswered: Subforrm - Removing Highlighted Record OnOpen

    Greetings,

    This is a problem that has been plaguing me for months. Tonight I thought I had it. It worked in AccessXP fine until I compacted the database, then the same old problem.

    I have a main form with a subform set to Continuous Forms. It is populated by a query but is not related to the main form.

    When the main form is opened, the record selected in the subform is highlighted. I want it not to be highlighted but have the cursor blinking on the left side of the text.

    From the google newsgroups I found some code that worked at first, but as noted above, could not withstand the compaction/repair. I got no errors, it just stopped working!

    Here is the code at the end of the OnOpen event of the form. I also tried it in the OnCurrent and in both but to no avail.


    Forms![frmEnter_Tasks]![subfrmEnter_Tasks].SetFocus
    Forms![frmEnter_Tasks]![subfrmEnter_Tasks]![txtTaskName].SetFocus

    SendKeys "{F2}"
    SendKeys "{HOME}"

    I am simply blown away that this could work for a while and then abjectly, totally fail. Any advice will be most appreciated.
    Regards, Kaniksu

  2. #2
    Join Date
    Aug 2003
    Posts
    106
    Being entirely honest, i have only used this in Excel VBA but it should work!

    form_open

    Forms![Name of form]![name of textbox].Selstart =0


    sugarflux

  3. #3
    Join Date
    Nov 2002
    Location
    Independence, Kansas
    Posts
    22
    Yes, thats right! I got the same response in the UK World Access and UtterAccess forums. My code block looks like this:

    Forms![frmEnter_Tasks]![subfrmEnter_Tasks].SetFocus
    Forms![frmEnter_Tasks]![subfrmEnter_Tasks]![txtTaskName].SetFocus
    Forms![frmEnter_Tasks]![subfrmEnter_Tasks]![txtTaskName].SelStart = 0

    =================================
    The other response was:

    Using "On Got Focus" for the field in question, try:

    Me.TextBoxName.SelStart = 0
    To select the end of the field you can use:
    Me.TextBoxName.SelStart = Me.TextBoxName.SelLength

    Note: If you want this feature for all fields, You can set this as a default option in Tools / Options / Keyboard
    Hope I am on the right track. Brad.

    The above may be more useful for me as I requery the subform with several controls on the Main form. Thanks for your reply!
    Regards, Kaniksu

Posting Permissions

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