For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic Syntax > April 2005 > How can I click a command button from code in another form?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How can I click a command button from code in another form?
Stan Hilliard

2005-04-08, 8:59 pm

Q1) How can I Click a command button from code in another form?

Say that Command1 is on SSTab1 which is on Form1.

I have determined the address (f) of Form1 from the forms collection.

I have tried "Call f.SSTab1.Command1_Click" and that didn't work.

What is the method to click the button?


Q2) Also, How can I set the SSTab to Tab1 from code in the other
form?.

Help will be appreciated, Stan Hilliard
Victor Koch

2005-04-08, 8:59 pm

Hi Stan,

FormName.CommandName.Value= True

FormNane.TabName.Tab=1

--
Víctor Koch.


"Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> escribió en el
mensaje news:2urd51hn5dp8cgkusist1thvumvmc8s3u0@
4ax.com...
> Q1) How can I Click a command button from code in another form?
>
> Say that Command1 is on SSTab1 which is on Form1.
>
> I have determined the address (f) of Form1 from the forms collection.
>
> I have tried "Call f.SSTab1.Command1_Click" and that didn't work.
>
> What is the method to click the button?
>
>
> Q2) Also, How can I set the SSTab to Tab1 from code in the other
> form?.
>
> Help will be appreciated, Stan Hilliard



Saga

2005-04-08, 8:59 pm


Have you tried:

f.Command1.value = true

or

form1.Command1.value = true

Did you dynamically create Form1 as f?
Not sure what you mean by "address (f) of Form1".

Good luck!
Saga


"Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote in
message news:2urd51hn5dp8cgkusist1thvumvmc8s3u0@
4ax.com...
> Q1) How can I Click a command button from code in another form?
>
> Say that Command1 is on SSTab1 which is on Form1.
>
> I have determined the address (f) of Form1 from the forms collection.
>
> I have tried "Call f.SSTab1.Command1_Click" and that didn't work.
>
> What is the method to click the button?
>
>
> Q2) Also, How can I set the SSTab to Tab1 from code in the other
> form?.
>
> Help will be appreciated, Stan Hilliard



Stan Hilliard

2005-04-08, 8:59 pm

On Fri, 8 Apr 2005 16:22:45 -0500, "Saga" <antiSpam@somewhere.com>
wrote:

>
>Have you tried:
>
>f.Command1.value = true
>
>or
>
>form1.Command1.value = true
>
>Did you dynamically create Form1 as f?
>Not sure what you mean by "address (f) of Form1".


I meant that I found the address of Form1 in the forms collection. I
do it this way because I can't be sure that the user has loaded the
form.
-----
For Each f In Forms
If f.Name = "frmTabsAttributeB" Then
f.txtAQLb = Format(AQL, "0.######") 'can be very small.
f.txtRQLb = txtRQL
f.txtAlpha = Format(1 - EAA, "0.######")
f.txtBeta = txtBeta
f.txtnSize = lngnSize
f.txtAc = txtAc
f.cmdCalculateRule.Value = True
f.SSTab1.Tab = 1
Hit = True
Exit For
End If
Next f
-----

My code is working now. Thanks to you and Victor.

>Good luck!
>Saga
>
>
>"Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote in
>message news:2urd51hn5dp8cgkusist1thvumvmc8s3u0@
4ax.com...
>


Stan Hilliard

2005-04-09, 8:57 pm

On Fri, 08 Apr 2005 17:11:13 -0500, Stan Hilliard
<usenetreplyMS@samplingplansNOTSPAM.com> wrote:

>On Fri, 8 Apr 2005 16:22:45 -0500, "Saga" <antiSpam@somewhere.com>


<snip>

>I meant that I found the address of Form1 in the forms collection. I
>do it this way because I can't be sure that the user has loaded the
>form.
>-----
> For Each f In Forms
> If f.Name = "frmTabsAttributeB" Then

<snip>
> f.SSTab1.Tab = 1
> Exit For
> End If
> Next f


This correctly switches to Tab1 of SSTab when the form that SSTab is
on is already loaded.

If the form is not loaded I load it before executing this code. But
there is a difference. In that case the code correctly writes the data
to the textboxes on the SSTab -- but it does not change to Tab1. Why
can it do one and not the other?

However, I can make it change to Tab1 by stopping execution
temporarily with an F9 breakpoint on
f.SSTab1.Tab = 1
and then F5 to continue.

What could be happening here and what can I do to make the tabbing
work?

Here is more of the actual code.

=======
If Not IsLoaded("frmTabsAttributeB") Then 'my function, below.
Call MDIForm1.StartAttributeBPlanner(6)
End If

'* write aql/rql points to tab2 of planner form.
For Each f In Forms
If f.Name = "frmTabsAttributeB" Then
f.txtAQLb = Format(AQL, "0.######") 'can be very small.
f.txtRQLb = txtRQL
f.txtAlpha = Format(1 - EAA, "0.######")
f.txtBeta = txtBeta
f.txtnSize = lngnSize
f.txtAc = txtAc
f.cmdCalculateRule.Value = True
f.SSTab1.Tab = 1
Exit For
End If
Next f
Unload Me
Exit Sub

<snip> error handler
End Sub

Function IsLoaded(Name As String) As Boolean
Dim f As Form
For Each f In Forms
If f.Name = Name Then
IsLoaded = True
Exit For
End If
Next f
End Function
=======



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com