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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel UserForm Listbox Problem

Status
Not open for further replies.

TheAceMan1

Programmer
Sep 23, 2003
11,174
US
Howdy Guys & Gals . . .

Excel 2003 UserForm

Have a userform with several listboxes. [purple]What I'm trying to do is set [blue]defaults[/blue] when the form opens[/purple]. Although I'm able to do this (at least as far as viewing the form is concerned), reading the form for insertion into a spreadsheet produces a problem ... [purple]I don't read the defaults after their set![/purple] ... very strange. To see what I mean note the link that follows. The defaults for the listboxes as viewed are correct. But when I read the listboxes (the messagebox overlay) some listboxes display no value! ... To be sure ... [purple]this is the problem![/purple]

Listbox Problem

Any Ideas as to why or what I can do?

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 


Ace,

As hard as I try, I cannot get code out of a jpg!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
How are ya SkipVought . . .

So sorry ... its a screen shot (.jpg) of the form with an overlay of a messaagebox. I believe you can click the icon to expand it into view. If not ... is their any place else I can upload for the cause?

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 



I guess you do not care to post your code where you are setting your listbox defaults et al.

O.L!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
SkipVought . . .

No ... just waiting for your response.

In the forms [blue]Initialize[/blue] event:
Code:
[blue]   lbxTester.Value = "CD/GA"
   lbxOrigPCB.Value = "PK-6019A U2"
   lbxReplPCB.Value = "PK-7034 U2"
   lbxTypeTest.Value = "Full Testing!"

   rPM = 2
   rPN = ""
   rHV = 4
   rSV = 2
   
   sPM = ""
   sPN = ""
   sHV = ""
   sSV = ""
   
   rrPM = ""
   rrPN = ""
   rrHV = ""
   rrSV = ""
   
   rLR = ""
   rLT = ""
   
   sLR = "B"
   sLT = 0
   
   rrLR = "B"
   rrLT = 0[/blue]
The form has a button for testing which pops a msgbox that displays the [blue]Value[/blue] property for each listbox:
Code:
[blue]   MsgBox "lbxTester.Value = " & lbxTester.Value & vbNewLine & _
          "lbxOrigPCB.Value = " & lbxOrigPCB.Value & vbNewLine & _
          "lbxReplPCB.Value = " & lbxReplPCB.Value & vbNewLine & _
          "lbxTypeTest.Value = " & lbxTypeTest.Value[/blue]
As I open, close & reopen the form ... randomly one or more listboxes show no value in the msgbox!

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 


Clearly each is selected. Yet you get this random behavior?

I am speeechless at a loss of words!

What happens if you recreate the form in a new workbook?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
SkipVought . . .

I'm saving recreation as a last resort ([purple]just doesn't seem like any corruption[/purple]). I'm currently researching as deep as I can get into the [blue]Initialize[/blue] event (I've also tried the Forms [purple]Activate[/purple] event with the same results). I'm starting to think this is a problem in Excel 2003 never noticed!

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
SkipVought . . .

I was able to fix/cure the problem.
TheAceMan1 said:
[blue]If I set focus to the listboxes 1st, before making any changes ... all works well![/blue]
Don't ask me how/why it works cause I sure couldn't tell ya.

There is one thing though ... the 1st time you insert a form in XL a reference is set to the [blue]Microsoft Forms 2.0 Object Library (or FM20.dll)[/blue]. I believe enough of the problem lies here.

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top