Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Location
    ny, ny
    Posts
    224

    Unanswered: Losing Focus for button

    I have a button AddProject1 (forecolor = blue)
    when I click on it , it makes my project lbl and txb visible and makes a button over it AddProject2(forecolor=brown) visible. Then when i click on AddProject2 it adds the new project.
    The problem I am having is I am unable to make the AdDProect1 invisible because it has the focus. Can someone help me out.

    Private Sub AddProject1_Click()

    'AddProject1.OnGotFocus = False
    'AddProject1.Visible = False
    txbProject.SetFocus
    AddProject1.Visible = False
    AddProject2.Visible = True
    lblProject.Visible = True
    txbProject.Visible = True
    'Call txbProject_OnUpdate

    End Sub

    Private Sub addproject2_click()

    Dim dbcw As Database
    Dim rsproject As DAO.Recordset
    Set dbcw = CurrentDb()
    Set rsproject = dbcw.OpenRecordset("tblProject")
    With rsproject
    .AddNew
    ![projectDesc] = Me.txbProject

    .Update
    .close
    End With

    AddProject1.Visible = True
    AddProject2.Visible = False
    lblProject.Visible = False
    txbProject.Visible = False


    End Sub

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Simply set focus somewhere else before making the button invisible.
    Paul

  3. #3
    Join Date
    Apr 2004
    Location
    ny, ny
    Posts
    224
    Thats what I have tried to do. I tried to move the focus to AddProject2 but it gives me an error msg "Cant move focus to control AddProject2"
    AddProject2.SetFocus
    AddProject1.Visible = False
    AddProject2.Visible = True
    lblProject.Visible = True
    txbProject.Visible = True

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    It would seem obvious that you can't set focus to AddProject2 until it's visible. Make it visible, then set focus to it, then hide the other one.
    Paul

  5. #5
    Join Date
    Apr 2004
    Location
    ny, ny
    Posts
    224
    Thank you very much. This fixed the issue

Posting Permissions

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