|
|
#1 |
|
Hyperactive Member
Join Date: Nov 06
Posts: 420
![]() |
I'm looking for a bit of advice before I try to do something.
I need to replicate the sort of form you get in MSAccess where you are selecting the fields you want in a query. There are two boxes - one on the left and one on the right and, between them, 4 buttons that allow you to: select one item from the box on the left and move it to the box on the right select all items from the box on the left and move to the right select one item from the right and move to the left select all items from the right and move to the left Which controls should I use? Two rich text boxes? Is there a built-in control in VB for this? I want users to be able to shift-click and control-click in either box to select items that are not necessarily next to each other etc. Appreciate any input on the best way to implement this. Thanks in advance. Last edited by Webskater; May 1st, 2007 at 08:31 AM. Reason: Missed something out |
|
|
|
|
|
#2 |
|
Super Moderator
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Field Picker
Attached is an example.
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Before posting your question, did you look here? Got a question on Linux? Visit our Linux sister site. I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum. ![]() Creating A Wizard In VB.NET Modifications Required For VB6 Apps To Work On Vista Paging A Recordset What is wrong with using On Error Resume Next Good Article: Language Enhancements In Visual Basic 2010 IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects! Upgrading VB6 Code To VB.NET Microsoft MVP 2005/2006/2007/2008/2009/2010 |
|
|
|
|
|
#3 |
|
Fanatic Member
Join Date: Jan 07
Location: Orissa,India
Posts: 622
![]() |
1.Use two list boxes and 4 buttons
2.Set the multiselect property of both 3.Try this code for moving selected items from list1 to list2 Code:
Private Sub Command1_Click()
For i = 0 To List1.ListCount - 1
If List1.List(i) = "" Then Exit For
If List1.Selected(i) = True Then
List2.AddItem List1.List(i)
List1.RemoveItem i
End If
Next
End Sub
|
|
|
|
|
|
#4 |
|
Super Moderator
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Field Picker
That is precisely what my example does with code for all 4 buttons.
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Before posting your question, did you look here? Got a question on Linux? Visit our Linux sister site. I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum. ![]() Creating A Wizard In VB.NET Modifications Required For VB6 Apps To Work On Vista Paging A Recordset What is wrong with using On Error Resume Next Good Article: Language Enhancements In Visual Basic 2010 IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects! Upgrading VB6 Code To VB.NET Microsoft MVP 2005/2006/2007/2008/2009/2010 |
|
|
|
|
|
#5 | |
|
Hyperactive Member
Join Date: Nov 06
Posts: 420
![]() |
Re: Field Picker
Quote:
|
|
|
|
|
|
|
#6 |
|
Fanatic Member
Join Date: Jan 07
Location: Orissa,India
Posts: 622
![]() |
Re: Field Picker
both of us have replied at the same time.!!
|
|
|
|
|
|
#7 |
|
Super Moderator
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Field Picker
I've use this type of thing in projects beyond count, including the one I'm currently working on.
Do you have any other questions on this topic?
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Before posting your question, did you look here? Got a question on Linux? Visit our Linux sister site. I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum. ![]() Creating A Wizard In VB.NET Modifications Required For VB6 Apps To Work On Vista Paging A Recordset What is wrong with using On Error Resume Next Good Article: Language Enhancements In Visual Basic 2010 IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects! Upgrading VB6 Code To VB.NET Microsoft MVP 2005/2006/2007/2008/2009/2010 |
|
|
|
|
|
#8 | |
|
Hyperactive Member
Join Date: Nov 06
Posts: 420
![]() |
Re: Field Picker
Quote:
Thanks again. (Blast - already marked thread as resolved!) |
|
|
|
|
|
|
#9 |
|
Super Moderator
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: [RESOLVED] Field Picker
By "ID" do you mean its ListIndex?
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Before posting your question, did you look here? Got a question on Linux? Visit our Linux sister site. I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum. ![]() Creating A Wizard In VB.NET Modifications Required For VB6 Apps To Work On Vista Paging A Recordset What is wrong with using On Error Resume Next Good Article: Language Enhancements In Visual Basic 2010 IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects! Upgrading VB6 Code To VB.NET Microsoft MVP 2005/2006/2007/2008/2009/2010 |
|
|
|
|
|
#10 |
|
Hyperactive Member
Join Date: Nov 06
Posts: 420
![]() |
Re: [RESOLVED] Field Picker
No, if I pull the data from a database - I mean the primary key associated with each item.
cheers |
|
|
|
|
|
#11 |
|
Super Moderator
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: [RESOLVED] Field Picker
You are loading lstFrom from a database table, right?
How many primary keys are there on this table?
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Before posting your question, did you look here? Got a question on Linux? Visit our Linux sister site. I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum. ![]() Creating A Wizard In VB.NET Modifications Required For VB6 Apps To Work On Vista Paging A Recordset What is wrong with using On Error Resume Next Good Article: Language Enhancements In Visual Basic 2010 IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects! Upgrading VB6 Code To VB.NET Microsoft MVP 2005/2006/2007/2008/2009/2010 |
|
|
|
|
|
#12 |
|
Super Moderator
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: [RESOLVED] Field Picker
Also, when you have selected what you want from lstFrom and move those items over to lstTo, what happens next?
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Before posting your question, did you look here? Got a question on Linux? Visit our Linux sister site. I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum. ![]() Creating A Wizard In VB.NET Modifications Required For VB6 Apps To Work On Vista Paging A Recordset What is wrong with using On Error Resume Next Good Article: Language Enhancements In Visual Basic 2010 IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects! Upgrading VB6 Code To VB.NET Microsoft MVP 2005/2006/2007/2008/2009/2010 |
|
|
|
|
|
#13 |
|
Hyperactive Member
Join Date: Nov 06
Posts: 420
![]() |
Re: [RESOLVED] Field Picker
The list on the left contains a list of products that users can click on to compare them.
So, when the list on the right is populated - they will click a 'Compare' button and I will pass the list of ProductIDs (hidden) in the list to retrieve the details from the database. Thanks again |
|
|
|
|
|
#14 |
|
Super Moderator
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: [RESOLVED] Field Picker
In what will these details be displayed?
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Before posting your question, did you look here? Got a question on Linux? Visit our Linux sister site. I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum. ![]() Creating A Wizard In VB.NET Modifications Required For VB6 Apps To Work On Vista Paging A Recordset What is wrong with using On Error Resume Next Good Article: Language Enhancements In Visual Basic 2010 IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects! Upgrading VB6 Code To VB.NET Microsoft MVP 2005/2006/2007/2008/2009/2010 |
|
|
|
|
|
#15 |
|
Hyperactive Member
Join Date: Nov 06
Posts: 420
![]() |
Re: [RESOLVED] Field Picker
Let's say the user decides to compare oranges, apples, pears and peaches. I'll be passing say 4,7,9,13 (the ProductIDs) as the parameters to a SQL statement to return various fields which I will then put into an excel spreadsheet for the user to import into their own reporting tool.
Cheers |
|
|
|
|
|
#16 |
|
Super Moderator
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: [RESOLVED] Field Picker
Ok, so if I'm reading you right, you need to build an IN clause which would read
Code:
IN ('oranges', 'apples', 'pears', 'peaches')
Is this right?
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Before posting your question, did you look here? Got a question on Linux? Visit our Linux sister site. I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum. ![]() Creating A Wizard In VB.NET Modifications Required For VB6 Apps To Work On Vista Paging A Recordset What is wrong with using On Error Resume Next Good Article: Language Enhancements In Visual Basic 2010 IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects! Upgrading VB6 Code To VB.NET Microsoft MVP 2005/2006/2007/2008/2009/2010 |
|
|
|
|
|
#17 |
|
Hyperactive Member
Join Date: Nov 06
Posts: 420
![]() |
Re: [RESOLVED] Field Picker
Hi, sorry, I'm not explaining myself very well.
I need to be able to associate a productID with the products listed in each box. So the one on the left might contain: 4 Oranges 7 Apples 6 Peaches 23 Pineapples 15 Plums 29 Grapefruit Where 4,7,6,23,15,29 are the respective Product IDs but which are hidden from the user. And, by the time the user has clicked on three products the right box might contain: 7 Apples 6 Peaches 15 Plums I need to be able to retrieve the ProductIDs - 7,6 and 15) so I can pass them to a Select statement whose WHERE clause will look like ... WHERE ProductID = 7 OR ProductID = 6 OR ProductID = 15 Cheers |
|
|
|
|
|
#18 |
|
Super Moderator
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: [RESOLVED] Field Picker
You are explaing yourself, but this
Code:
WHERE ProductID = 7 OR ProductID = 6 OR ProductID = 15 The way to do it is: Code:
WHERE productID IN (6, 7, 15)
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Before posting your question, did you look here? Got a question on Linux? Visit our Linux sister site. I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum. ![]() Creating A Wizard In VB.NET Modifications Required For VB6 Apps To Work On Vista Paging A Recordset What is wrong with using On Error Resume Next Good Article: Language Enhancements In Visual Basic 2010 IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects! Upgrading VB6 Code To VB.NET Microsoft MVP 2005/2006/2007/2008/2009/2010 |
|
|
|
|
|
#19 |
|
Hyperactive Member
Join Date: Nov 06
Posts: 420
![]() |
Re: [RESOLVED] Field Picker
Okay - understand you should use 'IN' instead of multiple 'ORs' - but how do I associate the ProductIDs with the Products in each box?
Cheers |
|
|
|
|
|
#20 |
|
Super Moderator
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: [RESOLVED] Field Picker
Tell me your database table design.
How are they laid out with respect to productIDs, products and product details? Are you using just one table for all of this or are there multiple tables involved? (Incidentially, until we get this worked out, edit the first post and backspace RESOLVED out of the thread title, then scroll down to the icon section and click No Icon - you can click the Mark Thread Resolved again later on.)
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Before posting your question, did you look here? Got a question on Linux? Visit our Linux sister site. I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum. ![]() Creating A Wizard In VB.NET Modifications Required For VB6 Apps To Work On Vista Paging A Recordset What is wrong with using On Error Resume Next Good Article: Language Enhancements In Visual Basic 2010 IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects! Upgrading VB6 Code To VB.NET Microsoft MVP 2005/2006/2007/2008/2009/2010 |
|
|
|
|
|
#21 |
|
Hyperactive Member
Join Date: Nov 06
Posts: 420
![]() |
Re: Field Picker
Been doing a bit of reading - I know what I need to do now but don't have the syntax to do it.
You wrote ... Code:
With lstFrom
.AddItem "Oranges"
.AddItem "Apples"
.AddItem "Pears"
.AddItem "Peaches"
.AddItem "Plums"
.AddItem "Prunes"
.AddItem "Bananas"
End With
.AddItem "Oranges" .ItemData(?) = 7 (i.e. the ProductID for Oranges) .AddItem "Apples" .ItemData(?) = 4 (i.e. the ProductID for Apples) I don't know what to put in as the index of ItemData - i.e. where I have put the '?' If I write ... 1stFrom.ItemData(1stFrom.ListIndex) it throws a wobbly and says the ListIndex = -1 But as you have just added a row I would have thought the ListIndex would be set to the current row? Cheers |
|
|
|
|
|
#22 |
|
Hyperactive Member
Join Date: Nov 06
Posts: 420
![]() |
Re: Field Picker
Have just figured out how to get the ProductIDs into the ItemDatas and out again.
Thanks again for all your help. |
|
|
|
|
|
#23 |
|
Super Moderator
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Field Picker
So, is this resolved again?
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Before posting your question, did you look here? Got a question on Linux? Visit our Linux sister site. I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum. ![]() Creating A Wizard In VB.NET Modifications Required For VB6 Apps To Work On Vista Paging A Recordset What is wrong with using On Error Resume Next Good Article: Language Enhancements In Visual Basic 2010 IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects! Upgrading VB6 Code To VB.NET Microsoft MVP 2005/2006/2007/2008/2009/2010 |
|
|
|
|
|
#24 |
|
Hyperactive Member
Join Date: Nov 06
Posts: 420
![]() |
Re: Field Picker
It is indeed.
Cheers |
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|