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

    Unanswered: how do you detect if the form active?

    There are two forms. One of the form will be inactive, meaning it will be dim in the back of the active form.

  2. #2
    Join Date
    Apr 2003
    Posts
    280
    No one knows? I'm surprised.. I could do this in Visual Basic(.ME) but not in access..

  3. #3
    Join Date
    Sep 2003
    Posts
    228
    Dim ctlCurrentControl As Control

    Set ctlCurrentControl = Screen.ActiveControl
    If ctlCurrentControl.Name = "txtCustomerID" Then
    .
    . ' Do something here.
    .
    ElseIf ctlCurrentControl.Name = "btnCustomerDetails" Then
    .
    . ' Do something here.
    .
    End If

  4. #4
    Join Date
    Sep 2003
    Posts
    228
    sorry dude, that was for active control

  5. #5
    Join Date
    Sep 2003
    Posts
    228
    This is what I meant:

    Dim frmCurrentFrom As Form

    Set frmCurrentFrom = Screen.ActiveForm
    If frmCurrentFrom.Name = "frmCustomer" Then
    .
    . ' Do something here.
    .
    ElseIf frmCurrentFrom.Name = "frmDetails" Then
    .
    . ' Do something here.
    .
    End If

  6. #6
    Join Date
    Apr 2003
    Posts
    280
    It doesn't works. I try putting "frmProductivity and Form_frmProductivity" as my form name.

  7. #7
    Join Date
    Sep 2003
    Posts
    228
    Try doing :
    msgbox frmCurrentFrom.Name

    just to see what form name is in the variable.

    What event are you working in?

  8. #8
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    you can use Screen.Activeform property I guess.forexample Screen.ActiveForm.Name gives name of the active form.
    ghozy.

  9. #9
    Join Date
    Nov 2003
    Posts
    1,487
    Try this......

    In the form(s) On GotFocus or On Activate event (code module):

    MsgBox Application.CurrentObjectName



Posting Permissions

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