Results 1 to 5 of 5

Thread: setfocus

  1. #1
    Join Date
    Apr 2009
    Posts
    85

    Unanswered: setfocus

    I have inherited a bare bones database and am tiring to make it more usable. I have made a search form with a subform. I have a txtbox on the form that when I lose focus I want to set focus on a txtbox on the subform using

    Forms!frmMyForm!Mysubform.Form!Mytxtbox.SetFocus

    Forms!frmDemoInventory!frmSubDemoInventory.Form!St atus.SetFocus

    Where status is on the subform
    But it's ignored. I can set focus on a different control on the form with out problem. Help please

  2. #2
    Join Date
    Feb 2004
    Posts
    214

    ...

    txtbox on your main form, you need to have an event procedure for lost focus.

    The code will look something like this.

    subformname!textboxname.setfocus
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  3. #3
    Join Date
    Apr 2009
    Posts
    85
    Thank you for replying Mr. Blond. Sorry was not clear I did have my code in the lost focus event. Maybe a more basic question is weather it matters if it is appended at the end of existing code. I have

    Private Sub txtDemo_LostFocus()

    ' Update the record source
    Me.frmSubDemoInventory.Form.RecordSource = "SELECT * FROM qrySubFrmDemoMaint " & BuildFilter

    ' Requery the subform
    Me.frmSubDemoInventory.Requery

    frmSubDemoInventory!Status.SetFocus

    End Sub

    I have tried many variants of set focus, I can set focus on a control not in the subform just fine

  4. #4
    Join Date
    Feb 2004
    Posts
    214

    ...

    make sure that your control in your subform is named Status and not something like Text1 or Combo1. I tried this in a sample database and it worked. If you want, you can attach a copy of your database with sample data and I can try to work on it and see what I can do.
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  5. #5
    Join Date
    Apr 2009
    Posts
    85
    I think this is how it's done. The event is being done from DemoId Combobox. Thanks for looking at this. Also(if you feel up to answering) do you know if with a check box you can turn the event off and then back on, I tried googling but no luck. Thanks again
    Attached Files Attached Files
    Last edited by Timothyl; 06-04-09 at 18:40.

Posting Permissions

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