Double-Clicking Item in Subform to Bring up Form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • z.ghulam@gmail.com

    Double-Clicking Item in Subform to Bring up Form

    Hi,

    I have a PROBLEM form with a TASK table embedded as a subform. Each
    problem can have many tasks.
    What I'm trying to do is when I double-click on the task ID, the TASK
    form opens up on that specific task.

    Any help would be greatly appreciated.

    Cheers
    Zieshan
  • Rick A.B.

    #2
    Re: Double-Clicking Item in Subform to Bring up Form

    On Apr 25, 8:48 am, z.ghu...@gmail. com wrote:
    Hi,
    >
    I have a PROBLEM form with a TASK table embedded as a subform. Each
    problem can have many tasks.
    What I'm trying to do is when I double-click on the task ID, the TASK
    form opens up on that specific task.
    >
    Any help would be greatly appreciated.
    >
    Cheers
    Zieshan
    Zieshan,

    In the doubleclick event of the TaskID put something like the
    following.

    Dim stDocName As String
    Dim stLinkCriteria As String


    stDocName = "NameOfForm "


    stLinkCriteria = "[linking field on form you are opening]=" & Me!
    [linking field on openform]


    DoCmd.OpenForm stDocName, , , stLinkCriteria

    That should open your form to the TaskID on your current record

    Hope that helps.

    Rick

    Comment

    • z.ghulam@gmail.com

      #3
      Re: Double-Clicking Item in Subform to Bring up Form

      On Apr 25, 3:25 pm, "Rick A.B." <rick.bre...@mi nneapolis.eduwr ote:
      On Apr 25, 8:48 am, z.ghu...@gmail. com wrote:
      >
      Hi,
      >
      I have a PROBLEM form with a TASK table embedded as a subform. Each
      problem can have many tasks.
      What I'm trying to do is when I double-click on the task ID, the TASK
      form opens up on that specific task.
      >
      Any help would be greatly appreciated.
      >
      Cheers
      Zieshan
      >
      Zieshan,
      >
      In the doubleclick event of the TaskID put something like the
      following.
      >
       Dim stDocName As String
       Dim stLinkCriteria As String
      >
       stDocName = "NameOfForm "
      >
       stLinkCriteria = "[linking field on form you are opening]=" & Me!
      [linking field on openform]
      >
       DoCmd.OpenForm stDocName, , , stLinkCriteria
      >
      That should open your form to the TaskID on your current record
      >
      Hope that helps.
      >
      Rick
      Thanks Rick - I'll give it a shot




      Comment

      • Phil Stanton

        #4
        Re: Double-Clicking Item in Subform to Bring up Form

        Try

        Private TaskID_DblClick (Cancel As Integer)

        If Not IsLoaded("Tasks ") Then
        DoCmd.OpenForm "Tasks"
        End If

        On Error Resume Next

        DoCmd.SelectObj ect acForm, "Tasks"
        DoCmd.Restore
        If Nz(TaskID) = 0 Then
        DoCmd.GoToRecor d acForm, "Tasks", acNewRec
        Else
        DoCmd.GoToContr ol "TaskID"
        DoCmd.FindRecor d TaskID
        End If

        End Sub

        Function IsLoaded(ByVal strFormName As String) As Integer
        ' Returns True if the specified form is open in Form view or Datasheet
        view.

        Const conObjStateClos ed = 0
        Const conDesignView = 0

        If SysCmd(acSysCmd GetObjectState, acForm, strFormName) <>
        conObjStateClos ed Then
        If Forms(strFormNa me).CurrentView <conDesignVie w Then
        IsLoaded = True
        End If
        End If

        End Function

        The code will find a record if it exists, or open the Tasks form up at a
        blank record if it doesn't exist
        The IsLoaded Function is quite useful to see if a form is open

        If you put this code in your Tasks form, it should show the new record in
        your subform

        Private Sub Form_AfterUpdat e()

        If IsLoaded("MyMai nForm") Then ' If called from
        member form
        If Nz(Forms!MyMain Form!MySubform. form!TaskID) = 0 Then '
        Empty
        Forms!MyMainFor m!MySubform.for m!TaskID = 0
        Forms!MyMainFor m!MySubform.for m!TaskID.Requer y
        Forms!MyMainFor m!MySubform.for m!TaskID = TaskID
        End If
        End If

        End Sub

        Phil

        <z.ghulam@gmail .comwrote in message
        news:c449287b-2608-441c-80e1-f02d98bf3f38@a2 2g2000hsc.googl egroups.com...
        On Apr 25, 3:25 pm, "Rick A.B." <rick.bre...@mi nneapolis.eduwr ote:
        On Apr 25, 8:48 am, z.ghu...@gmail. com wrote:
        >
        Hi,
        >
        I have a PROBLEM form with a TASK table embedded as a subform. Each
        problem can have many tasks.
        What I'm trying to do is when I double-click on the task ID, the TASK
        form opens up on that specific task.
        >
        Any help would be greatly appreciated.
        >
        Cheers
        Zieshan
        >
        Zieshan,
        >
        In the doubleclick event of the TaskID put something like the
        following.
        >
        Dim stDocName As String
        Dim stLinkCriteria As String
        >
        stDocName = "NameOfForm "
        >
        stLinkCriteria = "[linking field on form you are opening]=" & Me!
        [linking field on openform]
        >
        DoCmd.OpenForm stDocName, , , stLinkCriteria
        >
        That should open your form to the TaskID on your current record
        >
        Hope that helps.
        >
        Rick
        Thanks Rick - I'll give it a shot





        Comment

        Working...