PC Review


Reply
Thread Tools Rate Thread

Calling Button click event from Form initialise event?

 
 
noname
Guest
Posts: n/a
 
      10th Sep 2010
Hi,

I have a form with multipage containing 4 pages. Each page has frame
with controls like textboxes and comboboxes on it.

By clicking the Red X on title bar, i hide the form and load a
messagebox with Yes, No & Cancel buttons. If Cancel is chosen, the
hidden userform is made visible. But here's the catch, i need to open
the same page i was on, at the time of form hiding. Since on every
page, i have a button that has code which opens and initializes
controls on the next page, i need to know, can i call the button code
from the form initialize event, using an IF condition like this:

Userform_Initialize()
........
........
If p = 0 Then

'normal form initialization code....

ElseIf p = 1 Then

Call eqForm.cmd_AddBrands_Click

ElseIf p = 2 Then

Call eqForm.cmd_AddFactors01_Click

ElseIf p = 3 Then

Call eqForm.cmd_AddFactors02_Click

End If

End Sub


Anybody has ideas how to do this, instead of copy- pasting the
individual button_Click codes again into the form initialize event.
 
Reply With Quote
 
 
 
 
Mike S
Guest
Posts: n/a
 
      10th Sep 2010
On 9/10/2010 4:04 AM, noname wrote:
> Hi,
>
> I have a form with multipage containing 4 pages. Each page has frame
> with controls like textboxes and comboboxes on it.
>
> By clicking the Red X on title bar, i hide the form and load a
> messagebox with Yes, No& Cancel buttons. If Cancel is chosen, the
> hidden userform is made visible. But here's the catch, i need to open
> the same page i was on, at the time of form hiding. Since on every
> page, i have a button that has code which opens and initializes
> controls on the next page, i need to know, can i call the button code
> from the form initialize event, using an IF condition like this:
>
> Userform_Initialize()
> .......
> .......
> If p = 0 Then
> 'normal form initialization code....
> ElseIf p = 1 Then
> Call eqForm.cmd_AddBrands_Click
> ElseIf p = 2 Then
> Call eqForm.cmd_AddFactors01_Click
> ElseIf p = 3 Then
> Call eqForm.cmd_AddFactors02_Click
> End If
> End Sub
> Anybody has ideas how to do this, instead of copy- pasting the
> individual button_Click codes again into the form initialize event.


Try this:

If p = 0 Then
'normal form initialization code....
ElseIf p = 1 Then
eqForm.cmd_AddBrands.Value = True
ElseIf p = 2 Then
eqForm.cmd_AddFactors01.Value = True
ElseIf p = 3 Then
eqForm.cmd_AddFactors02.Value = True
End If
 
Reply With Quote
 
noname
Guest
Posts: n/a
 
      10th Sep 2010
On Sep 11, 1:17*am, Mike S <ms...@yahoo.com> wrote:
> On 9/10/2010 4:04 AM, noname wrote:
>
>
>
>
>
>
>
>
>
> > Hi,

>
> > I have a form with multipage containing 4 pages. Each page has frame
> > with controls like textboxes and comboboxes on it.

>
> > By clicking the Red X on title bar, i hide the form and load a
> > messagebox with Yes, No& *Cancel buttons. If Cancel is chosen, the
> > hidden userform is made visible. But here's the catch, i need to open
> > the same page i was on, at the time of form hiding. Since on every
> > page, i have a button that has code which opens and initializes
> > controls on the next page, i need to know, can i call the button code
> > from the form initialize event, using an IF condition like this:

>
> > Userform_Initialize()
> > .......
> > .......
> > * * *If p = 0 Then
> > * * * * *'normal form initialization code....
> > * * *ElseIf p = 1 Then
> > * * * * *Call eqForm.cmd_AddBrands_Click
> > * * *ElseIf p = 2 Then
> > * * * * *Call eqForm.cmd_AddFactors01_Click
> > * * *ElseIf p = 3 Then
> > * * * * *Call eqForm.cmd_AddFactors02_Click
> > * * *End If
> > End Sub
> > Anybody has ideas how to do this, instead of copy- pasting the
> > individual button_Click codes again into the form initialize event.

>
> Try this:
>
> If p = 0 Then
> * * *'normal form initialization code....
> ElseIf p = 1 Then
> * * *eqForm.cmd_AddBrands.Value = True
> ElseIf p = 2 Then
> * * *eqForm.cmd_AddFactors01.Value = True
> ElseIf p = 3 Then
> * * *eqForm.cmd_AddFactors02.Value = True
> End If


Thanks Mike,

You are fantabulous

This works!!!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
calling a website after a button click event John Timney \(MVP\) Microsoft C# .NET 6 26th Jul 2006 10:53 AM
code for calling a button event (click) ? (asp.net 2) moi Microsoft ASP .NET 2 8th Mar 2006 02:32 PM
Server Side button calling page_load before calling it's own click event. Ryan Ternier Microsoft ASP .NET 4 29th Jul 2004 02:06 PM
Re: Calling event from initialise function Konrad L. M. Rudolph Microsoft C# .NET 0 13th May 2004 08:29 PM
Calling a javascript function on asp:button's click event Praveen Ladwani Microsoft VB .NET 1 13th Jan 2004 08:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:12 PM.