listbox click event question

I am using Excel 2003. I have a two userforms, one with a listbox and
one with a commandbutton.  The click event of the listbox on userform1
hides the userform1 and shows userform2.  The commandbutton on
userform2  unloads userform2 and shows userform 1.

It works exactly as I want it for the first click of the listbox;
however, after the commandbutton on userform2 is clicedk to close
userform2 and show userform1, the click event on the listbox does not
fire.

This is initiating code

Sub test()
     UserForm1.Show
End Sub

This is the code for the listbox

Private Sub ListBox1_Click()
    Me.Hide
    UserForm2.Show
End Sub

This is the code for the commandbutton

Private Sub CommandButton1_Click()
    Unload Me
    UserForm1.Show
End Sub

When I change it so userform1 is unloaded, not just hidden, it works
repetitively.  I prefer not to unload userform1 because there is a
significant amount of data loaded and takes a few second each time.

Can anyone explain why this event is not triggered after the first
iteration of hiding and then redisplaying?

Thanks

Ken
0
Ken
1/11/2010 8:38:27 PM
excel.programming 6508 articles. 2 followers. Follow

4 Replies
1987 Views

Similar Articles

[PageSpeed] 56

Hi,

try this :

Private Sub CommandButton1_Click()
    Me.Hide
    UserForm1.Show
    Unload Me
End Sub





"Ken" <krcowen@aol.com> a �crit dans le message de groupe de discussion : 
a3e08e03-8204-44ea-a21f-2e903ac1c0dc@a21g2000yqc.googlegroups.com...
I am using Excel 2003. I have a two userforms, one with a listbox and
one with a commandbutton.  The click event of the listbox on userform1
hides the userform1 and shows userform2.  The commandbutton on
userform2  unloads userform2 and shows userform 1.

It works exactly as I want it for the first click of the listbox;
however, after the commandbutton on userform2 is clicedk to close
userform2 and show userform1, the click event on the listbox does not
fire.

This is initiating code

Sub test()
     UserForm1.Show
End Sub

This is the code for the listbox

Private Sub ListBox1_Click()
    Me.Hide
    UserForm2.Show
End Sub

This is the code for the commandbutton

Private Sub CommandButton1_Click()
    Unload Me
    UserForm1.Show
End Sub

When I change it so userform1 is unloaded, not just hidden, it works
repetitively.  I prefer not to unload userform1 because there is a
significant amount of data loaded and takes a few second each time.

Can anyone explain why this event is not triggered after the first
iteration of hiding and then redisplaying?

Thanks

Ken 

0
michdenis
1/11/2010 9:21:25 PM
That doesn't seem to help.  When I get back to userform1, the click
event still doesn't fire when I click on the listbox.  Also, now I
have to close the second userform twice before I get back to the first
userform; and I don't see the reason for that.

thanks

Ken

On Jan 11, 4:21=A0pm, "michdenis" <michde...@hotmail.com> wrote:
> Hi,
>
> try this :
>
> Private Sub CommandButton1_Click()
> =A0 =A0 Me.Hide
> =A0 =A0 UserForm1.Show
> =A0 =A0 Unload Me
> End Sub
>
> "Ken" <krco...@aol.com> a crit dans le message de groupe de discussion :
> a3e08e03-8204-44ea-a21f-2e903ac1c...@a21g2000yqc.googlegroups.com...
> I am using Excel 2003. I have a two userforms, one with a listbox and
> one with a commandbutton. =A0The click event of the listbox on userform1
> hides the userform1 and shows userform2. =A0The commandbutton on
> userform2 =A0unloads userform2 and shows userform 1.
>
> It works exactly as I want it for the first click of the listbox;
> however, after the commandbutton on userform2 is clicedk to close
> userform2 and show userform1, the click event on the listbox does not
> fire.
>
> This is initiating code
>
> Sub test()
> =A0 =A0 =A0UserForm1.Show
> End Sub
>
> This is the code for the listbox
>
> Private Sub ListBox1_Click()
> =A0 =A0 Me.Hide
> =A0 =A0 UserForm2.Show
> End Sub
>
> This is the code for the commandbutton
>
> Private Sub CommandButton1_Click()
> =A0 =A0 Unload Me
> =A0 =A0 UserForm1.Show
> End Sub
>
> When I change it so userform1 is unloaded, not just hidden, it works
> repetitively. =A0I prefer not to unload userform1 because there is a
> significant amount of data loaded and takes a few second each time.
>
> Can anyone explain why this event is not triggered after the first
> iteration of hiding and then redisplaying?
>
> Thanks
>
> Ken

0
Ken
1/11/2010 9:41:19 PM
You could use a combobox or

If you want to use a listbox, you will be obliged to use
an other event such as these : ListBox1_DblClick_Change or
 ListBox1_DblClick

For a reason i do not know, listbox1_click is not triggered when
Userform1 is activated  a second time..

it works !
'-----------------------------
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Me.Hide
Me.TextBox1.SetFocus
UserForm2.Show
End Sub
'-----------------------------





"Ken" <krcowen@aol.com> a �crit dans le message de groupe de discussion : 
9045bf42-2b39-47e6-bf36-b70e343fbbae@q4g2000yqm.googlegroups.com...
That doesn't seem to help.  When I get back to userform1, the click
event still doesn't fire when I click on the listbox.  Also, now I
have to close the second userform twice before I get back to the first
userform; and I don't see the reason for that.

thanks

Ken

On Jan 11, 4:21 pm, "michdenis" <michde...@hotmail.com> wrote:
> Hi,
>
> try this :
>
> Private Sub CommandButton1_Click()
>     Me.Hide
>     UserForm1.Show
>     Unload Me
> End Sub
>
> "Ken" <krco...@aol.com> a crit dans le message de groupe de discussion :
> a3e08e03-8204-44ea-a21f-2e903ac1c...@a21g2000yqc.googlegroups.com...
> I am using Excel 2003. I have a two userforms, one with a listbox and
> one with a commandbutton.  The click event of the listbox on userform1
> hides the userform1 and shows userform2.  The commandbutton on
> userform2  unloads userform2 and shows userform 1.
>
> It works exactly as I want it for the first click of the listbox;
> however, after the commandbutton on userform2 is clicedk to close
> userform2 and show userform1, the click event on the listbox does not
> fire.
>
> This is initiating code
>
> Sub test()
>      UserForm1.Show
> End Sub
>
> This is the code for the listbox
>
> Private Sub ListBox1_Click()
>     Me.Hide
>     UserForm2.Show
> End Sub
>
> This is the code for the commandbutton
>
> Private Sub CommandButton1_Click()
>     Unload Me
>     UserForm1.Show
> End Sub
>
> When I change it so userform1 is unloaded, not just hidden, it works
> repetitively.  I prefer not to unload userform1 because there is a
> significant amount of data loaded and takes a few second each time.
>
> Can anyone explain why this event is not triggered after the first
> iteration of hiding and then redisplaying?
>
> Thanks
>
> Ken 

0
michdenis
1/11/2010 10:39:53 PM
I already use the double click event for some other functionality.  I
guess I will have to come up with another work around; I'll probably
go back to unloading then reloading the form.

Thanks for you help.

Ken




On Jan 11, 5:39=A0pm, "michdenis" <michde...@hotmail.com> wrote:
> You could use a combobox or
>
> If you want to use a listbox, you will be obliged to use
> an other event such as these : ListBox1_DblClick_Change or
> =A0ListBox1_DblClick
>
> For a reason i do not know, listbox1_click is not triggered when
> Userform1 is activated =A0a second time..
>
> it works !
> '-----------------------------
> Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
> Me.Hide
> Me.TextBox1.SetFocus
> UserForm2.Show
> End Sub
> '-----------------------------
>
> "Ken" <krco...@aol.com> a =E9crit dans le message de groupe de discussion=
 :
> 9045bf42-2b39-47e6-bf36-b70e343fb...@q4g2000yqm.googlegroups.com...
> That doesn't seem to help. =A0When I get back to userform1, the click
> event still doesn't fire when I click on the listbox. =A0Also, now I
> have to close the second userform twice before I get back to the first
> userform; and I don't see the reason for that.
>
> thanks
>
> Ken
>
> On Jan 11, 4:21 pm, "michdenis" <michde...@hotmail.com> wrote:
>
>
>
> > Hi,
>
> > try this :
>
> > Private Sub CommandButton1_Click()
> > =A0 =A0 Me.Hide
> > =A0 =A0 UserForm1.Show
> > =A0 =A0 Unload Me
> > End Sub
>
> > "Ken" <krco...@aol.com> a crit dans le message de groupe de discussion =
:
> > a3e08e03-8204-44ea-a21f-2e903ac1c...@a21g2000yqc.googlegroups.com...
> > I am using Excel 2003. I have a two userforms, one with a listbox and
> > one with a commandbutton. =A0The click event of the listbox on userform=
1
> > hides the userform1 and shows userform2. =A0The commandbutton on
> > userform2 =A0unloads userform2 and shows userform 1.
>
> > It works exactly as I want it for the first click of the listbox;
> > however, after the commandbutton on userform2 is clicedk to close
> > userform2 and show userform1, the click event on the listbox does not
> > fire.
>
> > This is initiating code
>
> > Sub test()
> > =A0 =A0 =A0UserForm1.Show
> > End Sub
>
> > This is the code for the listbox
>
> > Private Sub ListBox1_Click()
> > =A0 =A0 Me.Hide
> > =A0 =A0 UserForm2.Show
> > End Sub
>
> > This is the code for the commandbutton
>
> > Private Sub CommandButton1_Click()
> > =A0 =A0 Unload Me
> > =A0 =A0 UserForm1.Show
> > End Sub
>
> > When I change it so userform1 is unloaded, not just hidden, it works
> > repetitively. =A0I prefer not to unload userform1 because there is a
> > significant amount of data loaded and takes a few second each time.
>
> > Can anyone explain why this event is not triggered after the first
> > iteration of hiding and then redisplaying?
>
> > Thanks
>
> > Ken- Hide quoted text -
>
> - Show quoted text -

0
Ken
1/11/2010 10:54:11 PM
Reply:

Similar Artilces:

Windows 7 Mail Question
Does Windows 7 have an included email application? If so, does it support IMAP, POP, SMTP, EXCHANGE and HTTP email configurations? Thank you. -Frank YES "Frankster" <frank@SPAM2TRASH.com> wrote in message news:ze6dnYRTr8IDfqXWnZ2dnUVZ_hOdnZ2d@giganews.com... > Does Windows 7 have an included email application? If so, does it support > IMAP, POP, SMTP, EXCHANGE and HTTP email configurations? > > Thank you. > > -Frank Windows 7 does not include an email program. I use the free Windows Live Mail,(http:\download.live.com) but ther...

refer to second column of listbox
Hi, I have a multi selected listbox. How can I refer to the second column of the listbox? Me.lstContract.ItemData(varItem).column(1) ??? Dim varItem As Variant For Each varItem In Me.lstContract.ItemsSelected gstrReportFilter = "[Ck_ContractID]='" & Me.lstContract.ItemData(varItem) & "'" ''DoCmd.OpenReport "rptCoFundActivity_k" '', , , gstrReportFilter DoCmd.OpenReport "rptCostShareContribution_k", acViewPreview '', , gstrReportFilter Next varItem SF ...

SMALL Function question
Hi All, First off, many thanks that assisted me in getting my golf score sheet running properly with the MATCH & INDEX stuff...it works great. I have a problem with the SMALL function...I have a list of 5 lowest scores returned from a range called 'calcutta'. In the adjacent cell I have the coresponding name returned ato match the score with the player. The problem is with ties. If two players hve the same score the SMALL function returns the first one it finds in each cell. I use it like this G1=SMALL(CALCUTTA,1) G2=SMALL(CALCUTTA,2) ETC.... "Monte Comeau" <...

VBA speed question.
I want to know that A() and B() which faster... dim arr(99) as long dim arrB(9) as long sub A() arr(arrB()) = arr(arrB()) + 1 end sub sub B() dim X as long X = arrB() arr(X) = arr(X) + 1 end sub ...

Installation Question
I would like to install Vista on a Macintosh I have. It's a 250 g hard drive, but I've already used up 150 g. Is there a way not to put on all that extra junk that comes with Windows? I've already bought it a year and a half ago, the macintosh hard drive was replaced. Thank you On 12 Jul 2010, safety123@aol.com wrote in microsoft.public.windows.vista.general: > I would like to install Vista on a Macintosh I have. > It's a 250 g hard drive, but I've already used up 150 g. > > Is there a way not to put on all that extra junk that comes with ...

Newbie question: finding aliases and forwards
If I have an address such as services@somewhere.com how could I figure out where (which user) that address exists at in Exchange or where it forwards to (if it forwards versus belonging to a user)? Thanks. just go to Active Directory Users and computers and do a find with a filter by the users email Address "Joe Blow" wrote: > If I have an address such as services@somewhere.com > how could I figure out where (which user) that address exists at in Exchange > or where it forwards to (if it forwards versus belonging to a user)? > Thanks. > > > ...

Simple charting question
I don't believe I'm having so much trouble with this. I'm trying to make a graph with Temperature (Celesius) as the X-axis and Baseball Speed (Km/hr) as the Y-axis. When I highlight the columns below and try to make a bar graph - 0 44.1 1 47 3 44.7 4 43.5 5 50.2 13 59.9 I get two series plotted or shown seperately. I would like to get one of the following: ...

Using a listbox selection to limit records in a form and report
I am trying to use a listbox of names to limit the results of a form to just those names. On a similar track, I want to use the selected names to limit a report. I have the listbox created and have added a button next to it to initiate the next step, but cannot figure out how to do it. Also, would like to (if possible) use multiple listboxs in the same way (ie, name and/or department). "dascooper" <dascooper@discussions.microsoft.com> wrote in message news:1227B7CC-3345-4FDC-8EB0-94BEF46660FD@microsoft.com... >I am trying to use a listbox of names to limit the resu...

2003 Money (Can I -) question
Is it possible to change or preset defaults for the drop down fields used to create new recurring bill under [Bills & Deposits]? For example; [Write Check] is the default in the payment method. I want it to be [Print Check]. [Monthly] is default for the frequency and I want [Only Once]. I would like to be able to set my most used selections as defaults. Thanks - Andy Nope. "Andy" <a1cotton@knology.net> wrote in message news:079b01c392c3$6cfe0290$a301280a@phx.gbl... > Is it possible to change or preset defaults for the drop > down fields used to create new...

All Day events cover 2 day
When I create an all day event or even an event that covers several days, it looks fine in monthly view if you look at it in a list view it spans over to two days. So when you sync your calendar your pda shows the event as 2 days. The default for an all day event is 12:00 am to 12:00 am is there a style sheet that can be changed to reflect an all day event to be 23 hours and 59 mins. Add the duration field to the view and you'll see they are only 1 day. If they spread over 2 days on the pda, check the time zone settings on the pda. -- Diane Poremsky [MVP - Outlook] Out...

Question about OleSetClipboard return CO_E_NOTINITIALIZED error!
When I using Clipboard function, for example below codes, SetClipboard() always is failed.I track into it and find OleSetClipboard return CO_E_NOTINITIALIZED. I depend on its tip and add Coinitialize() in. but It strill is wrong. who can help me? COleDataSource* pOds = new COleDataSource(); if (pOds == NULL) return FALSE; pOds->CacheGlobalData(nFormat,hMem); pOds->SetClipboard(); Michael F wrote: > When I using Clipboard function, for example below codes, > SetClipboard() always is failed.I track into it and find > OleSetClipboard return...

Great Plains Question 10-21-03
Can anyone tell me how Great Plains can be set up for 802.11b wireless scanners? Is the session just a regular Telnet session or is there some funky emulation? Also, is there any modules in place within Great Plains that allow portable RF scanners to operate? Given the fact that the portable scanner may only have a 16 x 21 line display. Or is it up to an integrator to set this up. please send this query to microsoft.public.greatplains "Kevin" <anonymous@discussions.microsoft.com> wrote in message news:00d301c39803$d049b0c0$a601280a@phx.gbl... > Can anyone tell...

XMLSPY Question
Altova posted an announcement regarding XMLSPY 2008 stating it can handle much larger files. So how large is large? Does it load the entire XML document into memory, or does it stream, like xmlreader? I read it has spyware so am reluctant to download the trial version. I did download Stylus Studio and it appears to be a DOM based system. I transform very large xml documents for my clients and some of these files are over 500Mb. I even did noe that was almost 3Gb. I wote some tools with xmlreader/writer that split the files, but requires some hard-coding for each one. sure would be nice to...

Event ID: 5011?????
I have exchange 5.5 sp4 running on a w2k dc server and I'm trying to add mailboxes/receipents and I get the error message, "an error occurred while processing an e-mail address. To view details of the error, see the application event log in the Windows NT Event Viewer on the Microsoft Exchange Server computer. Microsoft Exchange Administrator, ID no: c1030b35" and below is the error from the event viewer. I'm guessing it's permissions?? I've had no luck researching this, any ideas? ......TIA Event Type: Information Event Source: MSExchangeSA Event Category: Gener...

looping question
I've used a few looping type macros until now with no problems. However, I'm completely stumped when i need to get excel to count things for me>>> I have 5 row of data in each column (for example). I want to get all the data to be in column A each set below the next. so I need to refer to B1:B5 and move it to A6:A10. Then repeat to move C1:C5 to A11:A15 etc..etc... I need to move all 5 rows in each case regardless of content (number letter, blank etc..) I just come up against a brick wall when it comes to all this i=i+1 stuff, refering to ranges and telling excel to move ...

Billing/Statement Question w/Solomon Integration
Here is our company's structure: Our Corporate Office is being ran by Solomon, we have retail locations that will be running RMS for the retail counter sales.....We have many customers that not only call on us for service work, but also will come into the retail store to purchase products and services....When they make the purchase at the retail location, I would like them to be able to put their sale "on account", and once a month we can then bill them for their purchases. At the month end, I will need to be able to generate a statement that shows their activity for the ...

right click
can u disable the right click button in excel Hi, Alt+F11 to open VB editor. Double click 'ThisWorkbook' and paste this code in on the right Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean) Cancel = True End Sub -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "Steve davis" wrote: > can u disable the right click button in excel high work well thanks can it be done on the...

QS Hook Function Question
Based on the surfpro.dll example, I have roughed out a prospective function that I hope will allow me to initiate a membership style control over POS transactions. I'm not 100% sure how to call a QSBridge FireEvent -- ClearCustomer as the POS requires a Customer to complete a sale, so I figure no customer, or take away the customer, no sale... right? In VB6 this morning, the Date function, literally returned 6/28/2005. Great! If the Customer Expiration Date is stored in CustomDate1, then a quick subtraction and a few conditionals should do it. The subtraction returned an integer calc of t...

Outlook showing appointments as all day events when they are not
I am a (relatively) new user to outlook (XP home running under win98). Having set up a whole series of appointments (most of which are weekly reoccuring) outlook today is reporting some of them as all day events when they are not. Help suggests unchecking the all day event box - the check box is not showing on the problematic items - the items do not span more than (say) two hours and do not cross days. Have checked knowledge base cannot find anything - any ideas please? What do you show as the start and end times for any example appointment that exhibits this behavior? --� Milly Sta...

sumproduct question please
Hi everyone I have a list of names in column a - I then have data in various other columns which is copied from other worksheets (Columns B, F and J are names) I want to sum how many time a name in column a is listed in the others so have entered as: =SUMPRODUCT(($B$2:$B$500=A2)*($F$2:$F$500=A2)*($J$2:$J$500=A2)) But this is not calculating correctly - can someone pls advise what step I'm missing?? -- Thanks as always Lise Try =COUNTIF(A:A,A1)+COUNTIF(F:F,A1)+COUNTIF(J:J,A1) -- Jacob "Lise" wrote: > Hi everyone > > I have a list ...

One More Calendar Control Question
Seems as if there are many questions about the ActiveX calendar control and many warnings on not to use them. I have used them with some success, but some issues just make me scratch my head. I am currently using it to have the user select a start date and an end date to run a report. The form opens and the calendars are set to the current date. If the user clicks anywhere on the dates, the start or end date changes accordingly. The problem I have is when the user selects a different month or year, none of the dates are depressed. The user has to select a new date within the sel...

Toolbar Event Handler for .NET
What is the most simple way to add an Event Handler to a new Toolbar Button? In the context menu, I can not find any Add Event, only the properties dialog where there is nothing about events. I assume it is possible to add a handler by hand but I intend to have quite a few buttons so I want to simplify things a bit. I am using VS .NET om W XP prof. Thanks for any answer Anders Floderus ------------- m a i l : anders d o t floderus a t swipnet d o t se If you are using MFC, use ON_COMMAND and ON_UPDATE_COMMANDUI handlers for the button ID. YOu can put these in mainframe, document or vie...

Simple Question
I have a set of 20000 numbers , some of which are in one form, some in the other. How do I convert a number - like 3, to 003? Thanks, Jim Berglund Select all the cells; use menu command Format| Format Cells -> Custom Format and specify 000 as the format best wishes -- Bernard V Liengme www.stfx.ca/people/bliengme remove caps from email "Jim Berglund" <jazzzbo@shaw.ca> wrote in message news:D43_h.153712$DE1.42938@pd7urf2no... > > I have a set of 20000 numbers , some of which are in one form, some in the > other. > > How do I convert a number - lik...

OWA adds a single ? question mark character
When an e-mail is created and sent using OWA a single ?=20 quesiton mark charcter is added to the first line in the=20 body of the received e-mail sent to both internal and=20 external recipients. This only from 1 of my users. De : Gilles Trachsel=20 Envoy=E9 : vendredi, 6. ao=FBt 2004 09:05 =C0 : Brian K. Lockett Cc : Gilles Trachsel Objet : Test webmail ?=20 Test =20 =C3=A9=C3=A9=C3=A9=C3=A9=C3=A9=C3=A9=C3=A9=C3=A9=C3=A9=C3=A9=C3=A9=C3=A9=C3= =A9=C3=A9=C3=A9 =C3 =C3 =C3 =C3 =C3 =C3 =C3 =C3 =C3 =C3 =C3 =C3 =C3 =C3 =C3=20 =20 Regards, Gilles Is there anything different about this client, ...

Outlook Express question #2
What's the "Request a read receipt for all sent messages" in Outlook Express under the Receipts tab? If I send this to a person who reads their web email such as Hotmail, will this verfiy that the person has read that email? Please explain? Yes, when a person reads an e-mail that flag should prompt the client to return a notification that the message has been read. However, many mail clients can block the returning of a read receipt. Motto: Don't rely on read receipts. "Sam" <anonymous@discussions.microsoft.com> wrote in message news:71b801c494...