Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Form works once only

This routine works once, but fails on subsequent occassions.
Private Sub wholemonthbutton3_click()
ListBox1.ListIndex=0
ListBox2.ListIndex = ListBox2.ListCount - 1 ' This line fails
Msgbox "Listbox2.Value = " & ListBox2.Value _
& " Count =" & ListBox2.ListCount
end sub

The first time the sub works. The second time ListBox2.value =""
When the OK button is hit I have Unload Me.
When the routine has returned to the calling program I have Unload
DatesForGraph. Before the routine is called again I have the same statement.
So I think it should be unloaded 3 times but still it gives me the wrong
answer! Please advise where am I may be going wrong. (Excel 2003)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Form works once only

is there any data in listbox2 ?

you aren't clear on why you get the wrong answer, and if the form is
unloaded, does the forms load event correctly populaet whatever listboxes you
have?
Remember that if you unload a form, then any changes that were made are lost
unless saved somewhere else and re-loaded. Use HIDE to preserve values.



"Gleam" wrote:

This routine works once, but fails on subsequent occassions.
Private Sub wholemonthbutton3_click()
ListBox1.ListIndex=0
ListBox2.ListIndex = ListBox2.ListCount - 1 ' This line fails
Msgbox "Listbox2.Value = " & ListBox2.Value _
& " Count =" & ListBox2.ListCount
end sub

The first time the sub works. The second time ListBox2.value =""
When the OK button is hit I have Unload Me.
When the routine has returned to the calling program I have Unload
DatesForGraph. Before the routine is called again I have the same statement.
So I think it should be unloaded 3 times but still it gives me the wrong
answer! Please advise where am I may be going wrong. (Excel 2003)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Form works once only

Listbox2 displays the correct data every time.
I have several forms in the file and wonder if I have another ListBox2 in a
different form and Excel is getting confused.

I am thinking of trying this when I get a chance:
DatesForGraph.ListBox2.ListIndex = DatesForGraph.ListBox2.ListCount - 1
Listbox2.Value = DatesForGraph.Listbox2.Value
where form name=DatesForGraph

"Patrick Molloy" wrote:

is there any data in listbox2 ?

you aren't clear on why you get the wrong answer, and if the form is
unloaded, does the forms load event correctly populaet whatever listboxes you
have?
Remember that if you unload a form, then any changes that were made are lost
unless saved somewhere else and re-loaded. Use HIDE to preserve values.



"Gleam" wrote:

This routine works once, but fails on subsequent occassions.
Private Sub wholemonthbutton3_click()
ListBox1.ListIndex=0
ListBox2.ListIndex = ListBox2.ListCount - 1 ' This line fails
Msgbox "Listbox2.Value = " & ListBox2.Value _
& " Count =" & ListBox2.ListCount
end sub

The first time the sub works. The second time ListBox2.value =""
When the OK button is hit I have Unload Me.
When the routine has returned to the calling program I have Unload
DatesForGraph. Before the routine is called again I have the same statement.
So I think it should be unloaded 3 times but still it gives me the wrong
answer! Please advise where am I may be going wrong. (Excel 2003)

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros: Step Thru Works, Run Works, Keyboard Shortcut Locks up BEEJAY Excel Programming 2 October 3rd 06 06:46 PM
Alt-Tab works differently if Form called from Menu or Buttonbar Icon seisman Excel Programming 5 August 2nd 05 10:36 AM
How do I convert works file to excel without works software? CatMB Excel Discussion (Misc queries) 1 June 21st 05 04:12 PM
listbox works in form; not imbedded??? jasonsweeney[_66_] Excel Programming 3 April 15th 04 10:24 PM


All times are GMT +1. The time now is 11:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"