Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Listbox dbl click

Discussion in 'Information Technology' started by lmv, Jul 28, 2006.

Tags:
  1. lmv

    lmv
    Expand Collapse
    Guest

    Would someone be able to direct me to an article or an answer to how to dbl
    clk on a record in a subform list box and have it open the record in the
    parent form OrdersWDetails form.
    If more info is needed the following doesn't work OrderID is Number:
    Private Sub List0_DblClick(Cancel As Integer)
    Dim stDocName As String
    Dim stLinkCriteria As String
    'need to get this to open record clicked on don't know if it is DLookup or ??
    'stDocName = Me.OrderID.OrdersWDetails
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    End Sub
    Thanks!
     
  2. Dirk Goldgar

    Dirk Goldgar
    Expand Collapse
    Guest

    "lmv" <lmv@discussions.microsoft.com> wrote in message
    news:4BD16916-5CD7-4FC5-BC5D-03AB7EEEB6C2@microsoft.com
    > Would someone be able to direct me to an article or an answer to how
    > to dbl clk on a record in a subform list box and have it open the
    > record in the parent form OrdersWDetails form.
    > If more info is needed the following doesn't work OrderID is Number:
    > Private Sub List0_DblClick(Cancel As Integer)
    > Dim stDocName As String
    > Dim stLinkCriteria As String
    > 'need to get this to open record clicked on don't know if it is
    > DLookup or ?? 'stDocName = Me.OrderID.OrdersWDetails
    > DoCmd.OpenForm stDocName, , , stLinkCriteria
    >
    > End Sub


    I'm not sure I have this straight, so please check my understanding:

    You have a main form named "OrdersWDetails" -- yes?

    This form displays records containing a numeric OrderID field -- yes?

    The OrderID field is a unique key to the records displayed by the main
    form -- yes?

    On that form, there's a subform -- yes?

    On that subform, there's a list box named "List0" -- yes?

    The list box's bound column holds OrderID values -- yes?

    *IF* all that is true, then you can probably use code like this:

    '----- start of suggested code -----
    Private Sub List0_DblClick(Cancel As Integer)

    Dim frm As Form

    Set frm = Me.Parent

    With frm.RecordsetClone
    .FindFirst "OrderID = " & Me!List0
    If .NoMatch Then
    MsgBox "Order not found!"
    Else
    frm.Bookmark = .Bookmark
    End If
    End With

    Set frm = Nothing

    End Sub

    '----- end of suggested code -----

    --
    Dirk Goldgar, MS Access MVP
    www.datagnostics.com

    (please reply to the newsgroup)
     
  3. lmv

    lmv
    Expand Collapse
    Guest

    > You have a main form named "OrdersWDetails" -- yes?
    YES
    > This form displays records containing a numeric OrderID field -- yes?

    YES (OrderID is not a visible field)

    > The OrderID field is a unique key to the records displayed by the main
    > form -- yes?

    YES
    > On that form, there's a subform -- yes?

    YES
    > On that subform, there's a list box named "List0" -- yes?

    YES
    > The list box's bound column holds OrderID values -- yes?

    YES
    SELECT Orders.OrderID, Orders.OrderDate, Orders.PurchaseOrderNumber,
    qrySupplierIDLookup.SupplierName, Orders.RequestedBy FROM Orders LEFT JOIN
    qrySupplierIDLookup ON Orders.SupplierID = qrySupplierIDLookup.SupplierID
    ORDER BY Orders.PurchaseOrderNumber;
    5 COLUMNS
    0";0.7";0.8";2";0.7"

    I tried the code as suggested and got Runtime Error 2452 invalid referance
    to the parent property
    Set frm = Me.Parent

    I don't know what to try to fix it.

    > *IF* all that is true, then you can probably use code like this:
    >
    > '----- start of suggested code -----
    > Private Sub List0_DblClick(Cancel As Integer)
    >
    > Dim frm As Form
    >
    > Set frm = Me.Parent
    >
    > With frm.RecordsetClone
    > .FindFirst "OrderID = " & Me!List0
    > If .NoMatch Then
    > MsgBox "Order not found!"
    > Else
    > frm.Bookmark = .Bookmark
    > End If
    > End With
    >
    > Set frm = Nothing
    >
    > End Sub
    >
    > '----- end of suggested code -----
     
  4. Dirk Goldgar

    Dirk Goldgar
    Expand Collapse
    Guest

    "lmv" <lmv@discussions.microsoft.com> wrote in message
    news:12A7A8C1-FBDE-4778-A680-A0A7E675E6AE@microsoft.com
    > I tried the code as suggested and got Runtime Error 2452 invalid
    > referance to the parent property
    > Set frm = Me.Parent


    You should only get that error if the code is not executing on a
    subform. Are you *sure* your listbox is on a subform, and not on the
    main form? A subform, in this sense, is one that is displayed in a
    subform control on the parent form -- not just a standalone form that is
    related to the main form somehow.

    --
    Dirk Goldgar, MS Access MVP
    www.datagnostics.com

    (please reply to the newsgroup)
     
  5. lmv

    lmv
    Expand Collapse
    Guest

    No I am not sure... but now I think (from your questions) it is on the main
    form...
    It is an unbound list box on a tab
    tabSelectTransaction

    Sorry, so can dbl clicking the item in the list open it within the main form?
    lmv

    "Dirk Goldgar" wrote:

    > You should only get that error if the code is not executing on a
    > subform. Are you *sure* your listbox is on a subform, and not on the
    > main form? A subform, in this sense, is one that is displayed in a
    > subform control on the parent form -- not just a standalone form that is
    > related to the main form somehow.
    >
    > --
    > Dirk Goldgar, MS Access MVP
    > www.datagnostics.com
    >
    > (please reply to the newsgroup)
    >
    >
    >
     
  6. Dirk Goldgar

    Dirk Goldgar
    Expand Collapse
    Guest

    "lmv" <lmv@discussions.microsoft.com> wrote in message
    news:994FC14C-A898-4EB9-A8B8-AE83150A7366@microsoft.com
    > No I am not sure... but now I think (from your questions) it is on
    > the main form...
    > It is an unbound list box on a tab
    > tabSelectTransaction
    >
    > Sorry, so can dbl clicking the item in the list open it within the
    > main form?


    Sure, it's even easier. Just change the code as follows:

    '----- start of suggested code -----
    Private Sub List0_DblClick(Cancel As Integer)

    With Me.RecordsetClone
    .FindFirst "OrderID = " & Me!List0
    If .NoMatch Then
    MsgBox "Order not found!"
    Else
    Me.Bookmark = .Bookmark
    End If
    End With

    End Sub
    '----- end of suggested code -----

    --
    Dirk Goldgar, MS Access MVP
    www.datagnostics.com

    (please reply to the newsgroup)
     
  7. lmv

    lmv
    Expand Collapse
    Guest

    PERFECT... almost can you tell me how to send the focus back to:
    tabOrderDetails

    thank you! :~)

    "Dirk Goldgar" wrote:

    > "lmv" <lmv@discussions.microsoft.com> wrote in message
    > news:994FC14C-A898-4EB9-A8B8-AE83150A7366@microsoft.com
    > > No I am not sure... but now I think (from your questions) it is on
    > > the main form...
    > > It is an unbound list box on a tab
    > > tabSelectTransaction
    > >
    > > Sorry, so can dbl clicking the item in the list open it within the
    > > main form?

    >
    > Sure, it's even easier. Just change the code as follows:
    >
    > '----- start of suggested code -----
    > Private Sub List0_DblClick(Cancel As Integer)
    >
    > With Me.RecordsetClone
    > .FindFirst "OrderID = " & Me!List0
    > If .NoMatch Then
    > MsgBox "Order not found!"
    > Else
    > Me.Bookmark = .Bookmark
    > End If
    > End With
    >
    > End Sub
    > '----- end of suggested code -----
    >
    > --
    > Dirk Goldgar, MS Access MVP
    > www.datagnostics.com
    >
    > (please reply to the newsgroup)
    >
    >
    >
     
  8. Dirk Goldgar

    Dirk Goldgar
    Expand Collapse
    Guest

    "lmv" <lmv@discussions.microsoft.com> wrote in message
    news:4ED2638D-C9BB-4BE5-8A82-31F724934AB9@microsoft.com
    > PERFECT... almost can you tell me how to send the focus back to:
    > tabOrderDetails


    Is tabOrderDetails a tab control, or a page of a tab control?

    You could try this and see if it works:

    Me.tabOrderDetails.SetFocus

    You'd insert that line in the code after the With ... End With block,
    before the End Sub line.

    --
    Dirk Goldgar, MS Access MVP
    www.datagnostics.com

    (please reply to the newsgroup)
     
  9. lmv

    lmv
    Expand Collapse
    Guest

    NOW it is PERFECT!
    thanks!

    "Dirk Goldgar" wrote:

    > "lmv" <lmv@discussions.microsoft.com> wrote in message
    > news:4ED2638D-C9BB-4BE5-8A82-31F724934AB9@microsoft.com
    > > PERFECT... almost can you tell me how to send the focus back to:
    > > tabOrderDetails

    >
    > Is tabOrderDetails a tab control, or a page of a tab control?
    >
    > You could try this and see if it works:
    >
    > Me.tabOrderDetails.SetFocus
    >
    > You'd insert that line in the code after the With ... End With block,
    > before the End Sub line.
    >
    > --
    > Dirk Goldgar, MS Access MVP
    > www.datagnostics.com
    >
    > (please reply to the newsgroup)
    >
    >
    >
     

Share This Page