A form passing a parameter to another form
Please Help,
I am new VB programmer and would like to do the following things in VB6:
1. I want to pass a parameter from one form to anothr form. How would I
do this? Can I use the .Text value of a text control and have the second
form use this control .Text value? How will I pass this value to a stored
procedure of the second forms's ADO data control?
2. I would like to pop up a Modal form and select a row from a data grid
of this form, and bring some values to the calling form?
3. I have two data combo controls on a form that will allow the user to
select parts of General Ledger account numbers. The first control (dtcCostCenter)will
allow me to select the Cost Center of the Chart of Accounts. The second
control (dtcAccount) should allow the user to select only the Accounts that
belong to the Cost Center that was selected in the dtcCostCenter control.
The dtcCostCenter control is bound to an ADO Data Control which in turn
is bound to a Cost Center Table. The dtcAccount control is bound to another
ADO control that uses a Stored Procedure with a Where clause (Select CostCenter,
AccountNum from Accounts_T Where CostCenter = @CostCenter). How will I pass
this parameter to this stored procedure from the dtcCostCenter.Text and refresh
the ADO control that is bound to the dtcAccount contnrol?
I have about 5 books on VB6 but none of them show me the solution to these
problems.
Thanks for your help!
Bill
After modifying the SQL statement of the ADO data control how will I refresh
the contents of the
Re: A form passing a parameter to another form
In your books you should find some information on scope of variables.
Variables or object properties that are declared public can be read by other
modules/forms.
If you need to use a modal form, do not unload it until you get the
information you need from it. In the modal form, call me.hide and then
unload it from the parent form after you finish collecting the information
you need.
--
Andrew Grillage
http://vbdata.iwarp.com
"Bill Gaddam" <williamg@bytes-intl.com> wrote in message
news:38fe31f2$1@news.devx.com...
>
> Please Help,
>
> I am new VB programmer and would like to do the following things in VB6:
>
> 1. I want to pass a parameter from one form to anothr form. How would I
> do this? Can I use the .Text value of a text control and have the second
> form use this control .Text value? How will I pass this value to a stored
> procedure of the second forms's ADO data control?
>
> 2. I would like to pop up a Modal form and select a row from a data grid
> of this form, and bring some values to the calling form?
>
> 3. I have two data combo controls on a form that will allow the user to
> select parts of General Ledger account numbers. The first control
(dtcCostCenter)will
> allow me to select the Cost Center of the Chart of Accounts. The second
> control (dtcAccount) should allow the user to select only the Accounts
that
> belong to the Cost Center that was selected in the dtcCostCenter control.
> The dtcCostCenter control is bound to an ADO Data Control which in turn
> is bound to a Cost Center Table. The dtcAccount control is bound to
another
> ADO control that uses a Stored Procedure with a Where clause (Select
CostCenter,
> AccountNum from Accounts_T Where CostCenter = @CostCenter). How will I
pass
> this parameter to this stored procedure from the dtcCostCenter.Text and
refresh
> the ADO control that is bound to the dtcAccount contnrol?
>
> I have about 5 books on VB6 but none of them show me the solution to these
> problems.
>
> Thanks for your help!
>
> Bill
> After modifying the SQL statement of the ADO data control how will I
refresh
> the contents of the
Re: A form passing a parameter to another form
You should really use properties. The code below should help you.
Liam
http://www.vbexpress.com
'// Call the child form like this.
Private cmdChild_Click()
Dim f as frmChild
Set f = New frmChild
f.Show vbModal
if f.RC = vbOK then
Msgbox 'Selected Grid Id is' & f.Id
end if
Set f = Nothing
End Sub
'// In the child form, you'll have 2 properties. RC tells
'// what the user pressed and id tells you the id of the
'// record selected on the grid.
Private mRC As VbMsgBoxResult '// RC property.
Private mId As Long '// Id property.
Public Property Let RC(ByVal vRC As VbMsgBoxResult)
mRC = vRC
End Property
Public Property Get RC() As VbMsgBoxResult
RC = mRC
End Property
Public Property Let Id(ByVal vId As Long)
mId = vId
End Property
Public Property Get Id() As Long
Id = mId
End Property
Private Sub cmdOK_Click()
RC = vbOK
Id = SelectedIdonGrid()
End Sub
Private Sub Command1_Click()
RC = vbCancel
Id = -1
End Sub
"Andrew Grillage" <andrew@iishvara.com> wrote:
>In your books you should find some information on scope of variables.
>Variables or object properties that are declared public can be read by other
>modules/forms.
>
>If you need to use a modal form, do not unload it until you get the
>information you need from it. In the modal form, call me.hide and then
>unload it from the parent form after you finish collecting the information
>you need.
>
>--
>Andrew Grillage
>http://vbdata.iwarp.com
>
>
>"Bill Gaddam" <williamg@bytes-intl.com> wrote in message
>news:38fe31f2$1@news.devx.com...
>>
>> Please Help,
>>
>> I am new VB programmer and would like to do the following things in VB6:
>>
>> 1. I want to pass a parameter from one form to anothr form. How would
I
>> do this? Can I use the .Text value of a text control and have the second
>> form use this control .Text value? How will I pass this value to a stored
>> procedure of the second forms's ADO data control?
>>
>> 2. I would like to pop up a Modal form and select a row from a data grid
>> of this form, and bring some values to the calling form?
>>
>> 3. I have two data combo controls on a form that will allow the user
to
>> select parts of General Ledger account numbers. The first control
>(dtcCostCenter)will
>> allow me to select the Cost Center of the Chart of Accounts. The second
>> control (dtcAccount) should allow the user to select only the Accounts
>that
>> belong to the Cost Center that was selected in the dtcCostCenter control.
>> The dtcCostCenter control is bound to an ADO Data Control which in turn
>> is bound to a Cost Center Table. The dtcAccount control is bound to
>another
>> ADO control that uses a Stored Procedure with a Where clause (Select
>CostCenter,
>> AccountNum from Accounts_T Where CostCenter = @CostCenter). How will
I
>pass
>> this parameter to this stored procedure from the dtcCostCenter.Text and
>refresh
>> the ADO control that is bound to the dtcAccount contnrol?
>>
>> I have about 5 books on VB6 but none of them show me the solution to these
>> problems.
>>
>> Thanks for your help!
>>
>> Bill
>> After modifying the SQL statement of the ADO data control how will I
>refresh
>> the contents of the
>
>