Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms Wizard "Like" Listbox Transfer?

Status
Not open for further replies.

BradB

MIS
Jun 21, 2001
237
US
I'm tyring to find an example of the following interface. It's just like the forms wizard in Access 2000. I need to create an interface just like the following. I plan on adding the selected fields to the database.

Available Selected Fields
____________ _____________
| | | |
| | -> | |
| | ->> | |
| | | |
| | <- | |
| | <<- | |
|__________| |___________|


Brad Boydston
bboydston@bertnash.org
 
>I suggest you purchase the book.

That doesn't exactly help. Spending $50 bucks for a piece of code seems a bit much.

In VB I would have used:
For I = 0 To List1.ListCount - 1
If list1.Selected(I) Then
list2.AddItem list1.List(I)
End If

Next I
list1.RemoveItem list1.ListIndex


In Access:
For I = 0 To List1.ListCount - 1
If list1.Selected(I) Then ???

I want to be able to move data back and forth between the list boxes.

Brad Boydston

 
are the items in hte list contained in a table?
 
Yes, the list is contained in a table.

List1:
Row Source Type: Table/Query
Row Source:SELECT [Staff].[stf_id], [Staff].[stf_ln] FROM Staff;

List2:
Row Source Type: Value List
Row Source:

Values in List2 will be added to a different table in the database by StaffID by clicking on a CommandButton.

 
use the list1 to contain two columns:
ID and description (ID is not visible)

Private Sub CommandMoveOne_Click()

strSql = &quot;INSERT INTO tblAssigned &quot; & _
&quot;SET Stf_id = &quot; & List1.Value

ConnObj.Execute(strSql)

end Sub

Private Sub CommandMoveAll_Click()

For I = 0 To List1.ListCount - 1
If list1.Selected(I) Then
strSql = &quot;INSERT INTO tblAssigned &quot; & _
&quot;SET RelationID = &quot; & List1.ItemData(I).Value
ConnObj.Execute(strSql)
end if
Next

end Sub

Is this what you needed?

Alcar
 
Not exactly. I want to move items from list1 to list2. When the user is satistifed with the results of list2, THEN I'll update the table. So, you DID help me append the table, but I still need to know how to move data from list1 to list2. Thanks!
 
ohhh hehe gotcha:

i = List1.ListCount()
List2.AddItem(List1.value,i)
List2.Refresh

' and if you want that item to dissapear from the list1

List1.RemoveItem(List1.SelectedItem)

HTH
Alcar
 
Hi!

Just put another field in the table (yes/no type) and have both list boxes based on a query.

List1:
Row Source Type: Table/Query
Row Source:SELECT [Staff].[stf_id], [Staff].[stf_ln] FROM Staff Where SelectList = no;

List2:
Row Source Type: Table/Query
Row Source:SELECT [Staff].[stf_id], [Staff].[stf_ln] FROM Staff Where SelectList = yes;

Now all you need to do when they click a button is change the value of SelectList for the selected items and requery both list boxes.

hth
Jeff Bridgham
 
AddItem and RemoveItem are not used in Access Listboxes. I really don't want to use Forms 2.0 Listboxes. I would really like to use the Access listbox.
 
Jebry, a very good suggestion. I wish I could do just what you have described, but the table is an ODBC cource on a unix box. I can't add to the table unfortuantly. I suppose I could create and array with the value.

I'm suprised there more information on how to make your own wizard-like interface--two textboxes. When I figure out how to do it, I'm going to post it as a Helpful Tip.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top