Hi Jeff,
My goal is to update one table using paired list boxes using
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsmart04/html/sa04e1.asp
and using them to move fields from one table to another. What I am trying
to do is move selected, or all of the fields from one list box/table to
another listbox/table. Maybe there is an easier way to do this then using
MSDN's example. I am trying to learn MS Access as much as develop a DB.
I have three fields that I want to move; DayNumber, fkyClassTime, and
ClassDescription. The ClassDescription is a concatenation of 3 fields
Inserted into tblSource from SQL. I also want to keep the ClassDescription
in DayNumber/ClassTime order in both tables.
I can get one of the fields to move from one table to the other but not the
remaining two. I thought if I could dynamically change the BoundColumn
property I could accomplish this. Is there a better way?
Here is the code (with some of my own modifications) from the above URL;
Private Sub btnSelect_Click()
Dim rsSource As DAO.Recordset
Dim rsDestination As DAO.Recordset
If Me.lbSource.ItemsSelected.Count = 0 Then
Beep
Exit Sub
End If
Set rsSource = CurrentDb.OpenRecordset("tblSource", dbOpenDynaset)
Set rsDestination = CurrentDb.OpenRecordset("DestinationTable",
dbOpenDynaset)
For Each itm In Me.lbSource.ItemsSelected
rsDestination.AddNew
MyData = Me.lbSource.ItemData(itm)
rsDestination!Description = Me.lbSource.ItemData(itm)
rsDestination.Update
rsSource.FindFirst "Description = '" & Me.lbSource.ItemData(itm) &
"'"
rsSource.Edit
rsSource.Delete
Next itm
Me.lbSource.Requery
Me.lbDestination.Requery
End Sub
----- Original Message -----
From: Jeff Boyce
Newsgroups: microsoft.public.access.forms
Sent: Sunday, December 26, 2004 8:49 AM
Subject: Re: List Box bound column
Gary
It sounds like you've already determined the approach you want to make
work.
Perhaps if you describe the "why", the 'group readers can offer another
approach.