On Dbl Click function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Supermansteel
    New Member
    • Dec 2007
    • 73

    On Dbl Click function

    I have created a Form with two list boxes.....One contains State/Branches that have not been completed and a second list box that has State/branches that have been completed. Basically, has two list boxes are next to each other with no duplicates in both. They utilize the same same table and have a third column as a boolean Yes/No(completed). What I was thinking was if I double clicked on a particular State/Branch in the not completed list that it would automatically update my Completed column as yes and move it over to the other list box and vice versus. Is this possible? Also, would i have to create the two list boxes as a subform or are two listboxes ok? Any help would be greatly appreciated.
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    This most certainly can be accomplished, and here is the General Template, assuming the Primary Key in your Table is the Bound Column for cboNotCompleted :
    Code:
    Private Sub cboNotCompleted_DblClick(Cancel As Integer)
    Dim strSQL As String
    strSQL = "Update <Your Table Name> Set <Your Table Name>.[Completed] = True Where <Your Table Name>.[<Primary Key>] = " & Me![cboNotCompleted] & ";"
    CurrentDb.Execute strSQL, dbFailOnError
    
    Me![cboCompleted].Requery
    Me![cboNotCompleted].Requery
    End Sub

    Comment

    • hjozinovic
      New Member
      • Oct 2007
      • 167

      #3
      You could use Column Property for this too.
      This would require that your Combo-boxes are based on a queries that include three columns in this order: State;Branches; Completed (Completed being third)
      And column widths property of comboboxes must be set to e.g.: 2;2;0
      (Zero for third column)
      And column count property must be set to: 3

      On Double click event of cboCompleted put:
      Code:
      Me!cboCompleted.Column(2) = No
      Me!cboCompleted.Requery
      Me!cboNotCompleted.Requery
      On Double click event of cboNotCompleted put:
      Code:
      Me!cboNotCompleted.Column(2) = Yes
      Me!cboCompleted.Requery
      Me!cboNotCompleted.Requery

      Comment

      • Supermansteel
        New Member
        • Dec 2007
        • 73

        #4
        I have been playing with this for an hour now and can not figure it out. Here is my VB Code that I updated the information from my table:
        Private Sub cboNotCompleted _DblClick(Cance l As Integer)
        Dim strSQL As String
        strSQL = "Update Sample_Branches Set Sample_Branches .[Completed] = True Where Sample_Branches .[Sample_ID] = " & Me![cboNotCompleted] & ";"
        CurrentDb.Execu te strSQL, dbFailOnError
        Me![cboCompleted].Requery
        Me![cboNotCompleted].Requery
        End Sub

        In my Form, List2 Box My Row Source is such:
        SELECT Sample_Branches .ST, Sample_Branches .BR, Sample_Branches .Completed, Sample_Branches .Sample_ID
        FROM Sample_Branches
        WHERE (((Sample_Branc hes.Completed)= Yes));
        and Vice versus =No for List4 box
        Under Propertiese I have Column Count as 4, Coulmn Heads=Yes,Colum n Widths=1,1,0,0; Bound Column=4.

        Do you see what I am doing wrong?

        Matt

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Originally posted by Supermansteel
          I have been playing with this for an hour now and can not figure it out. Here is my VB Code that I updated the information from my table:
          Private Sub cboNotCompleted _DblClick(Cance l As Integer)
          Dim strSQL As String
          strSQL = "Update Sample_Branches Set Sample_Branches .[Completed] = True Where Sample_Branches .[Sample_ID] = " & Me![cboNotCompleted] & ";"
          CurrentDb.Execu te strSQL, dbFailOnError
          Me![cboCompleted].Requery
          Me![cboNotCompleted].Requery
          End Sub

          In my Form, List2 Box My Row Source is such:
          SELECT Sample_Branches .ST, Sample_Branches .BR, Sample_Branches .Completed, Sample_Branches .Sample_ID
          FROM Sample_Branches
          WHERE (((Sample_Branc hes.Completed)= Yes));
          and Vice versus =No for List4 box
          Under Propertiese I have Column Count as 4, Coulmn Heads=Yes,Colum n Widths=1,1,0,0; Bound Column=4.

          Do you see what I am doing wrong?

          Matt
          Substitute List2 and List4 for my cbo examples.

          Comment

          • Supermansteel
            New Member
            • Dec 2007
            • 73

            #6
            Originally posted by ADezii
            Substitute List2 and List4 for my cbo examples.
            Wow, worked like a charm. Your the best.

            Matt

            Comment

            Working...