Drag and drop in list box

V

V.P.

Hi all,

I need to build an import form. I have 2 list boxes, first called lstSource
with the values of columns headers from an excel file (the excel file is not
always have same column headers) and lstDestination with values of fieldname
of a fixed table name.
lstSource lstDestination
Company AddressID
Title Company
First Name Title
Middle Initial FirstName
Last Name MI
Address LastName
City Address
State City
ZipCode StateorProvince
PostalCode
Notes
LastModified
Now I would like the user can drag value from lstSource to lstDestination or
switch (move up and down) the order of lstDestination list in order to match
the column of lstSource... or what ever can map the 2 ... then when user
finish that and hit a command Import button, it will append data from excel
file to table corresponding...

Please give me some advice how to do it...
Thanks in advance...
VP
 
M

Mr. Smith

I have done this sort of thing before. Let me warn you that going down the
drag and drop path is fiddly and there is an easier way.

Firstly, I gather you are already loading a table behind the scenes that
captures the column headers in the spreadsheet right? What I did was I had a
table that had two columns in it. One called ReceivingField and one called
LoadField. ReceivingField was permanently populated with the names of the
fields I wanted to import TO. LoadField was cleared after I imported my
data. I know what you're trying to acheive so I know you'll understand.

The solution though was that I created a form (to be used as a subform) that
was based on this table. The ReceivingField was displayed in a text box and
Loadfield was in a combo box. The list values available in LoadField's combo
came from the list of Spreadsheet column headers you already have (as I
described in the previous paragraph). I displayed this form as a datasheet
so the user could see each Receiving Field listed in the left column and the
load field column was blank. The user could then select the Spreadsheet
column header from the list to correspond to the receiving field wherever
there was an appropriate match.

What you end up with is a reference table that allows you to marry changing
import field names with fixed receiving field names. It worked a treat.
Obviously its not as glamorous as drag & drop but it provided the fix and
avoided the headaches of drag & drop coding.


Hope this helps


Mr. Smith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top