By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,203 Members | 1,401 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,203 IT Pros & Developers. It's quick & easy.

On Dbl Click function

P: 73
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.
Sep 23 '08 #1
Share this Question
Share on Google+
5 Replies


ADezii
Expert 5K+
P: 8,638
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:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboNotCompleted_DblClick(Cancel As Integer)
  2. Dim strSQL As String
  3. strSQL = "Update <Your Table Name> Set <Your Table Name>.[Completed] = True Where <Your Table Name>.[<Primary Key>] = " & Me![cboNotCompleted] & ";"
  4. CurrentDb.Execute strSQL, dbFailOnError
  5.  
  6. Me![cboCompleted].Requery
  7. Me![cboNotCompleted].Requery
  8. End Sub
Sep 23 '08 #2

100+
P: 167
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:
Expand|Select|Wrap|Line Numbers
  1. Me!cboCompleted.Column(2) = No
  2. Me!cboCompleted.Requery
  3. Me!cboNotCompleted.Requery
On Double click event of cboNotCompleted put:
Expand|Select|Wrap|Line Numbers
  1. Me!cboNotCompleted.Column(2) = Yes
  2. Me!cboCompleted.Requery
  3. Me!cboNotCompleted.Requery
Sep 24 '08 #3

P: 73
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(Cancel As Integer)
Dim strSQL As String
strSQL = "Update Sample_Branches Set Sample_Branches.[Completed] = True Where Sample_Branches.[Sample_ID] = " & Me![cboNotCompleted] & ";"
CurrentDb.Execute 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_Branches.Completed)=Yes));
and Vice versus =No for List4 box
Under Propertiese I have Column Count as 4, Coulmn Heads=Yes,Column Widths=1,1,0,0; Bound Column=4.

Do you see what I am doing wrong?

Matt
Sep 24 '08 #4

ADezii
Expert 5K+
P: 8,638
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(Cancel As Integer)
Dim strSQL As String
strSQL = "Update Sample_Branches Set Sample_Branches.[Completed] = True Where Sample_Branches.[Sample_ID] = " & Me![cboNotCompleted] & ";"
CurrentDb.Execute 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_Branches.Completed)=Yes));
and Vice versus =No for List4 box
Under Propertiese I have Column Count as 4, Coulmn Heads=Yes,Column 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.
Sep 24 '08 #5

P: 73
Substitute List2 and List4 for my cbo examples.
Wow, worked like a charm. Your the best.

Matt
Sep 24 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.