copy item from multi-column list box to paste in a different form

lscheer

Registered User.
Local time
Today, 22:52
Joined
Jan 20, 2000
Messages
185
This seems relatively simple, and of course I can get it to work, but not the way I want.

I have a search results form that displays a list box using two columns (first column stores ID and is hidden). When I select the item in the list box to paste into a different form, the value pasted is of course the value from the first (ID) column. I need to get the value from the second column pasted but the

DoCmd.GoToControl MyListBox.Column(1)
DoCmd.RunCOmmand acCmdCopy

gives me the following debug msg:

RunTime Error 2019
There is no field named "ListBox Column 1 contents" in the current record.


Any suggestions on what I cando instead?

Thx
 
Forms!OtherFormName.FieldOnOtherForm = Me.MyListBox.Column(1)

Hopefully you aren't storing this value, just displaying it.
 
Actually, I was hoping to store it...to "copy' it from the lookup box contents and "paste" it into a field on the main form.

It's being used if a person can't find a value in a combo box, they click on a button to search for a keyword within a value in the combo box using a custom dialog box. Since some of the values are rather complicated (spelling, nomenclature, etc.), I was hoping to paste the correct value (selected by the user) into the field to prevent them from having to re-type it.
 
Well, normally you would just store the ID and get the value associated with that from the table that holds them. In any case, I'm not picturing what you've got, so hopefully the code I gave above does the trick?
 
The procedure recommended above achieves the goal of pasting the value into the field I want (I had to change Column (1) to Column (0) because the columnd 0 contents are numerical and won't allow me to paste any text (i.e. from column 1) into that field. But anytime I'm on a record that doesn't need the value pasted into it, I get a continual loop error relating to the field data types. Also, it updates the "pasted" value in all associated records...which I don't want!

The purpose of this procedure is to fill in the contents of a field in ONE record. It is to be used when a user can't find the value they want in a very large list box, they open up a search form where they can enter a keyword from the value and get a set of results returned from which they can choose. I had hoped to be able to set it up so the user could select the item they are looking for and have it updated in the main form from their selection without them having to re-type it.

I'm still looking for a good way to do this! Thanks!


------------------------------------------------------------------

ACTUALLY, PBALDY'S SUGGESTION DOES WORK. It had to be in the Click event of the Update command button I was using, not the list box.

Thanks again!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom