atw: Re: Persistent Data in Userform List box [SEC= UNCLASSIFIED ]

Howard

And worth a play it was oh learned one. Reimplemented along the lines you
suggested and it resolved the problem.

Still can't help wondering why you can't just keep passing the re-referenced
object back and forth between the forms. It seemed to me to be a more
efficient way to do it. However I was clearly mistaken as the proof is in
the pudding as they say.

Thanks for taking the time out to assist. 

Cheers
Lucas

-----Original Message-----
From: austechwriter-bounce@xxxxxxxxxxxxx
[mailto:austechwriter-bounce@xxxxxxxxxxxxx] On Behalf Of Silcock, Howard DR
Sent: Friday, 19 May 2006 3:14 PM
To: austechwriter@xxxxxxxxxxxxx
Subject: atw: Re: Persistent Data in Userform List box [SEC= UNCLASSIFIED ]

(Resending this with the VB code removed, as it seems to produce error
messages)

Hi Lucas

After just a quick look at your code, I can't help thinking it would be
easier to make your Public variable - the one that records which list you're
currently working with - into a number rather than an object. A number is
enough to distinguish the various list boxes in Form 1. Then you can make
your procedure cmbSecurity1_1_Click() assign the value 1 to the public
variable while cmbSecurity1_2_Click() assigns the value 2 (and so on, if you
have further list boxes). You could then modify the code in each of your
_Click() subs to read values from, or write them to, a specific list box in
Form 1 depending on the number stored in that variable. (You could even set
up an array to store the names of the different list boxes in Form 1, so you
can retrieve the one appropriate to the current value of the public
variable.) That seems a much more natural way to proceed. I can't tell
whether that's going to fix your problem without actually trying, but I
think it might be worth playing with.  

HTH

Howard


-----Original Message-----
From: austechwriter-bounce@xxxxxxxxxxxxx
[mailto:austechwriter-bounce@xxxxxxxxxxxxx] On Behalf Of Lucas Simpson
Sent: Friday, 19 May 2006 13:45
To: austechwriter@xxxxxxxxxxxxx
Subject: atw: Persistent Data in Userform List box


Howdy Listies

Just can't seem to solve this so hoping someone can point out my stupidity.

Basic Scenario:
1. Have Form 1 with List box
2. Click Add button on Form 1 to load Form 2 and sync a list box on Form
2 with same list items as in Form 1 list box. 3. After Editing list, click
OK on Form 2 to pass Form 2 list items back to Form 1 list box.
- Have multiple list boxes on Form 1 (with a concommittant Add button) that
all use the same Form 2 for editing as per 1 to 3 above.

Code works no problem, can pass back and forth between Form 1 and Form 2
listboxes.

Problem is:
1. Add list values using above method to first listbox on Form 1. So far so
good. 2. Add list values using above method to second listbox on Form 1. So
far so good. 3. Attempt to re-edit first listbox on Form 1 and the values
from the second listbox on Form 1 still appear in Form 2 listbox.
Not good. 4. Cancel Form 2 (which unloads form) and then attempt step 3
again. Now the correct list values (ie. from first listbox on Form 1) load
into Form 2 listbox.

This suggests to me that Form 2 is not correctly unloading after passing
values back to Form 1 (on click OK). But buggered if i know why as Form
2 is instructed to unload on the OK click event, just as it is on the Cancel
click event.

Sure would appreciate someone giving me a clue.

OR Is there a better way for me to inform Form 2 about which list box in
Form 1 i am referring to. Can't seem to just pass the relevant Form 1 list
box object directly to the Form 2 Userform_Initialize sub.


Hope this makes sense.

Cheers
Lucas



----------------------------------
     Howard L. Silcock
      Technical Writer
 Common Services SOE Program
Network Infrastructure Development
    Department of Defence
      109 Kent Street
      Deakin ACT 2600           
      (02) 626 58395
----------------------------------


**************************************************
To post a message to austechwriter, send the message to
austechwriter@xxxxxxxxxxxxxx

To subscribe to austechwriter, send a message to
austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject field.

To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with
"unsubscribe" in the Subject field.

To search the austechwriter archives, go to
www.freelists.org/archives/austechwriter

To contact the list administrator, send a message to
austechwriter-admins@xxxxxxxxxxxxx
**************************************************
**************************************************
To post a message to austechwriter, send the message to 
austechwriter@xxxxxxxxxxxxxx

To subscribe to austechwriter, send a message to 
austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject field.

To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with 
"unsubscribe" in the Subject field.

To search the austechwriter archives, go to 
www.freelists.org/archives/austechwriter

To contact the list administrator, send a message to 
austechwriter-admins@xxxxxxxxxxxxx
**************************************************

Other related posts: