Click to See Complete Forum and Search --> : DATAGRID / DATAENVIRONMENT
Hutty
May 25th, 2000, 10:07 PM
I have a datagrid that's connected to a COMMAND. What I would like to do is change part of the sql statement at run-time. Currently the "where name " is hard coded. I want the "where name =" to be whatever name is displayed in combo1.text. At run-time, all i need is to change my combo1.text and it updates the command for my data grid. I don't have a clue. So, if there's a solution out there, i'm pretty much going to need an example.
Thanks.
JHausmann
May 26th, 2000, 02:29 AM
something like?
strSQL= "select * from table where name='" & trim(combo1.text) & "'"
Hutty
May 29th, 2000, 07:59 PM
I'm sorry, I was a little vague on my previous post. The COMMAND is SQL Comand inside of a Data Environment. Again, I would like the name(LFDIV) to be equal to combo1.text. Here's the current code within the SQL Command:
SELECT Name, Account, Qtr1
FROM Act
WHERE (Name = 'lfdiv') AND (Account = 'ret_prem_g' OR
Account = 'nii_gaap_inya' OR
Account = 'reclass_rcg' OR
Account = 'tot_revenue' OR
Account = 'tot_benefit' OR
Account = 'tot_inc_fpb' OR
Account = 'tot_acq_exp' OR
Account = 'opex_gaap_inya' OR
Account = 'tot_deduct' OR
Account = 'life_gaap_opinc' OR
Account = 'tot_rcg_bef_taxmi' OR
Account = 'life_net_inc')
Edneeis
May 30th, 2000, 01:47 PM
Just use the Filter method.
SQL.Filter="name='" & trim(combo1.text) & "'"
Hutty
May 30th, 2000, 11:15 PM
ED,
I'm not sure how to use the code in my SQL Command code stated above. I tried pasting where the name is reference, but didn't work. An example would be very helpful. THANKS
Edneeis
May 31st, 2000, 05:17 PM
Private Sub DataCombo1_Click(Area as integer)
'Makes sure the click is in the dropdown box and there is something selected
If Area=2 And DataCombo1.text<>"" then
'Assuming the name of the DataEnvironment is de and the command is SQL and field is Where_Name
de.SQL.Filter="Where_Name='" & DataCombo1.text & "'"
'This filters through the recordset and pulls out any records that match the criteria in the filter
End if
End Sub
Is that a little more clear? If not then feel free to tell me or email me.
[Edited by Edneeis on 06-01-2000 at 06:19 AM]
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.