Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 Datagrid

Status
Not open for further replies.

mgiblin

IS-IT--Management
Oct 1, 2003
1
US
I am querying my access database via a SQL statement then verifying it against a condition. It presents me with the correct information but, when I add it to the datagrid it shows me everything in the database. The command is - 'Set MatchGrid.DataSource = RS' which is adding the entire record source to the datagrid. What I'm looking for is a way to add the data that meets my condition into the datagrid. It could be one, two or three rows of data filling about 4 to 5 columns. If you can provide some assistance that would be greatly appreciated.

Thanks in advance,

Matt
 
I'm not sure what you mean by 'verifying it against a condition' but is this an ADO recordset? If so, you could consider using the Filter property where this contains the same condition. It would be helpful to see a bit more code.
 
Can't you include the condition in the SQL query's WHERE component? That way your recordset should only contain the data matching it and when you feed the datagrid with your recordset, you shouldn't be seeing any non-matching data.


"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)
 
sSql = "Select * From tablename Where ......(Condition)"
Set rsFind = New ADODB.Recordset

rsFind.CursorLocation = adUseClient
rsFind.Open sSql, adoConnect,adOpenKeyset, adLockOptimistic

Set datagrid1.DataSource = rsFind
datagrid1.ClearFields
datagrid1.ReBind
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top