Home » Category » Microsoft Excel

Microsoft Excel: Zorder doing strange things

205| Thu, 22 May 2008 04:49:00 GMT| anonymous| Comments (5)
Can anybody explain what's going on here ?

Put two listboxes and two commandbuttons on a form and
partially overlap the two listboxes. The code below should
alternately bring to the front and then to the rear Listbox2.

Private Sub CommandButton1_Click()
ListBox2.ZOrder (0)
End Sub

Private Sub CommandButton2_Click()
ListBox2.ZOrder (1)
End Sub

Here is what I'm seeing:

1. Run the form and it works fine. (or it may not work)
2. close the form
3. add a blank(if necessary) to the code and do a SAVE
4. run the form again and now it DOES NOT Work.
5. you can keep doing this and it alternates from WORKING to
NOT WORKING every time you do a SAVE.

I'm using Excel 2003. WORD does the same thing.

Keywords & Tags: zorder, doing, strange, things, microsoft, excel

URL: http://www.developertags.com/microsoft-excel/495228/
 
«« Prev - Next »» 5 helpful answers below.
Maybe just redrawing the userform would help:

Option Explicit
Private Sub CommandButton1_Click()
me.ListBox2.ZOrder 0
Me.Repaint
End Sub
Private Sub CommandButton2_Click()
me.ListBox2.ZOrder 1
Me.Repaint
End Sub

Ken Soenen wrote:
> Can anybody explain what's going on here ?
> Put two listboxes and two commandbuttons on a form and
> partially overlap the two listboxes. The code below should
> alternately bring to the front and then to the rear Listbox2.
> Private Sub CommandButton1_Click()
> ListBox2.ZOrder (0)
> End Sub
> Private Sub CommandButton2_Click()
> ListBox2.ZOrder (1)
> End Sub
> Here is what I'm seeing:
> 1. Run the form and it works fine. (or it may not work)
> 2. close the form
> 3. add a blank(if necessary) to the code and do a SAVE
> 4. run the form again and now it DOES NOT Work.
> 5. you can keep doing this and it alternates from WORKING to
> NOT WORKING every time you do a SAVE.
> I'm using Excel 2003. WORD does the same thing.
--

Dave Peterson

dave | Thu, 22 May 2008 04:51:00 GMT |

Dave,
Tried your idea and it still does the same thing.
Thanks anyway

"Dave Peterson" <petersod...verizonXSPAM.net> wrote in message
news:438F83A5.FD7E6F87...verizonXSPAM.net...
> Maybe just redrawing the userform would help:
>
> Option Explicit
> Private Sub CommandButton1_Click()
> me.ListBox2.ZOrder 0
> Me.Repaint
> End Sub
> Private Sub CommandButton2_Click()
> me.ListBox2.ZOrder 1
> Me.Repaint
> End Sub
> Ken Soenen wrote:
>> Can anybody explain what's going on here ?
>> Put two listboxes and two commandbuttons on a form and
>> partially overlap the two listboxes. The code below should
>> alternately bring to the front and then to the rear Listbox2.
>> Private Sub CommandButton1_Click()
>> ListBox2.ZOrder (0)
>> End Sub
>> Private Sub CommandButton2_Click()
>> ListBox2.ZOrder (1)
>> End Sub
>> Here is what I'm seeing:
>> 1. Run the form and it works fine. (or it may not work)
>> 2. close the form
>> 3. add a blank(if necessary) to the code and do a SAVE
>> 4. run the form again and now it DOES NOT Work.
>> 5. you can keep doing this and it alternates from WORKING to
>> NOT WORKING every time you do a SAVE.
>> I'm using Excel 2003. WORD does the same thing.
> --
> Dave Peterson

ken | Thu, 22 May 2008 04:52:00 GMT |

It was enough to make it work ok for me.

Maybe adding doEvents would help?

Ken Soenen wrote:
> Dave,
> Tried your idea and it still does the same thing.
> Thanks anyway
> "Dave Peterson" <petersod...verizonXSPAM.net> wrote in message
> news:438F83A5.FD7E6F87...verizonXSPAM.net...
> > Maybe just redrawing the userform would help:
> >
> >
> > Option Explicit
> > Private Sub CommandButton1_Click()
> > me.ListBox2.ZOrder 0
> > Me.Repaint
> > End Sub
> > Private Sub CommandButton2_Click()
> > me.ListBox2.ZOrder 1
> > Me.Repaint
> > End Sub
> >
> > Ken Soenen wrote:
> >>
> >> Can anybody explain what's going on here ?
> >>
> >> Put two listboxes and two commandbuttons on a form and
> >> partially overlap the two listboxes. The code below should
> >> alternately bring to the front and then to the rear Listbox2.
> >>
> >> Private Sub CommandButton1_Click()
> >> ListBox2.ZOrder (0)
> >> End Sub
> >>
> >> Private Sub CommandButton2_Click()
> >> ListBox2.ZOrder (1)
> >> End Sub
> >>
> >> Here is what I'm seeing:
> >>
> >> 1. Run the form and it works fine. (or it may not work)
> >> 2. close the form
> >> 3. add a blank(if necessary) to the code and do a SAVE
> >> 4. run the form again and now it DOES NOT Work.
> >> 5. you can keep doing this and it alternates from WORKING to
> >> NOT WORKING every time you do a SAVE.
> >>
> >> I'm using Excel 2003. WORD does the same thing.
> >
> > --
> >
> > Dave Peterson
--

Dave Peterson

dave | Thu, 22 May 2008 04:53:00 GMT |

Dave,
Were you actually able to alternately make it work and fail by using
the SAVE from the menu bar? This seems really crazy.!!!
ken
"Dave Peterson" <petersod...verizonXSPAM.net> wrote in message
news:439069B0.859DCD6F...verizonXSPAM.net...
> It was enough to make it work ok for me.
> Maybe adding doEvents would help?
> Ken Soenen wrote:
>> Dave,
>> Tried your idea and it still does the same thing.
>> Thanks anyway
>> "Dave Peterson" <petersod...verizonXSPAM.net> wrote in message
>> news:438F83A5.FD7E6F87...verizonXSPAM.net...
>> > Maybe just redrawing the userform would help:
>> >
>> >
>> > Option Explicit
>> > Private Sub CommandButton1_Click()
>> > me.ListBox2.ZOrder 0
>> > Me.Repaint
>> > End Sub
>> > Private Sub CommandButton2_Click()
>> > me.ListBox2.ZOrder 1
>> > Me.Repaint
>> > End Sub
>> >
>> > Ken Soenen wrote:
>> >>
>> >> Can anybody explain what's going on here ?
>> >>
>> >> Put two listboxes and two commandbuttons on a form and
>> >> partially overlap the two listboxes. The code below should
>> >> alternately bring to the front and then to the rear Listbox2.
>> >>
>> >> Private Sub CommandButton1_Click()
>> >> ListBox2.ZOrder (0)
>> >> End Sub
>> >>
>> >> Private Sub CommandButton2_Click()
>> >> ListBox2.ZOrder (1)
>> >> End Sub
>> >>
>> >> Here is what I'm seeing:
>> >>
>> >> 1. Run the form and it works fine. (or it may not work)
>> >> 2. close the form
>> >> 3. add a blank(if necessary) to the code and do a SAVE
>> >> 4. run the form again and now it DOES NOT Work.
>> >> 5. you can keep doing this and it alternates from WORKING to
>> >> NOT WORKING every time you do a SAVE.
>> >>
>> >> I'm using Excel 2003. WORD does the same thing.
>> >
>> > --
>> >
>> > Dave Peterson
> --
> Dave Peterson

ken | Thu, 22 May 2008 04:54:00 GMT |

I didn't use the save at all. I added me.repaint and it worked fine.

Ken Soenen wrote:
> Dave,
> Were you actually able to alternately make it work and fail by using
> the SAVE from the menu bar? This seems really crazy.!!!
> ken
> "Dave Peterson" <petersod...verizonXSPAM.net> wrote in message
> news:439069B0.859DCD6F...verizonXSPAM.net...
> > It was enough to make it work ok for me.
> >
> > Maybe adding doEvents would help?
> >
> > Ken Soenen wrote:
> >>
> >> Dave,
> >> Tried your idea and it still does the same thing.
> >> Thanks anyway
> >>
> >> "Dave Peterson" <petersod...verizonXSPAM.net> wrote in message
> >> news:438F83A5.FD7E6F87...verizonXSPAM.net...
> >> > Maybe just redrawing the userform would help:
> >> >
> >> >
> >> > Option Explicit
> >> > Private Sub CommandButton1_Click()
> >> > me.ListBox2.ZOrder 0
> >> > Me.Repaint
> >> > End Sub
> >> > Private Sub CommandButton2_Click()
> >> > me.ListBox2.ZOrder 1
> >> > Me.Repaint
> >> > End Sub
> >> >
> >> > Ken Soenen wrote:
> >> >>
> >> >> Can anybody explain what's going on here ?
> >> >>
> >> >> Put two listboxes and two commandbuttons on a form and
> >> >> partially overlap the two listboxes. The code below should
> >> >> alternately bring to the front and then to the rear Listbox2.
> >> >>
> >> >> Private Sub CommandButton1_Click()
> >> >> ListBox2.ZOrder (0)
> >> >> End Sub
> >> >>
> >> >> Private Sub CommandButton2_Click()
> >> >> ListBox2.ZOrder (1)
> >> >> End Sub
> >> >>
> >> >> Here is what I'm seeing:
> >> >>
> >> >> 1. Run the form and it works fine. (or it may not work)
> >> >> 2. close the form
> >> >> 3. add a blank(if necessary) to the code and do a SAVE
> >> >> 4. run the form again and now it DOES NOT Work.
> >> >> 5. you can keep doing this and it alternates from WORKING to
> >> >> NOT WORKING every time you do a SAVE.
> >> >>
> >> >> I'm using Excel 2003. WORD does the same thing.
> >> >
> >> > --
> >> >
> >> > Dave Peterson
> >
> > --
> >
> > Dave Peterson
--

Dave Peterson

dave | Thu, 22 May 2008 04:55:00 GMT |

Microsoft Excel Hot Answers

Microsoft Excel New questions

Microsoft Excel Related Categories