Best way to restrict data in a DBGrid? 
Author Message
 Best way to restrict data in a DBGrid?

I want to take a DBGrid and show data from a Datasource that points to an
Access Database.  But, I want to restrict the records that are displayed to
be based upon certain criteria.  What is the best way to implement this with
an existing DBGrid's relationship with a datasource?  Thanks very much in
advance.

....Brad



Sat, 22 Apr 2000 03:00:00 GMT  
 Best way to restrict data in a DBGrid?

This is a multi-part message in MIME format.

------=_NextPart_000_01BCE9DA.7DAAF730
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Brad,

I needed the same capability.  I have a screen with over 50 checkboxes the
user needs to select from, then I use a base sequel statement to implement
the routine.

EXAMPLE:

data1.Recordset.Requery
a = InputBox("Please input the Inmate Last name you wish to search for:",
"Inmate Last Name record Search")
If a = "" Then
    Exit Sub
    End If
 Screen.MousePointer = 11
SelectVariable = "[Inmate Last Name]"

If Check3 = 1 Then
        SelectVariable = SelectVariable & "," & "[First Name]"
        data1.RecordSource = "SELECT " & SelectVariable & " from COMPLNTS
where [Inmate Last Name] like '" & UCase(a) & "*';"
        End If
If Check4 = 1 Then
        SelectVariable = SelectVariable & ", " & "[Inmate Number]"
        data1.RecordSource = "SELECT " & SelectVariable & " from COMPLNTS
where [Inmate Last Name] like '" & UCase(a) & "*';"
        End If
If Check5 = 1 Then
        SelectVariable = SelectVariable & ", " & "[Institution Code]"
        data1.RecordSource = "SELECT " & SelectVariable & " from COMPLNTS
where [Inmate Last Name] like '" & UCase(a) & "*';"
        End If

Data1.refresh

END CODE:

This works great and not only finds the specific records I want but
displays ONLY the fields which the user has requested.  It is also very
fast.  With a database of over 500,000 records it takes about 8 seconds to
run no matter what checkboxes are selected.

--
Sincerely,

Todd W. Butson
Department of Corrections - State of Wisconsin
(608) 261-7118 Voice




Quote:
> I want to take a DBGrid and show data from a Datasource that points to an
> Access Database.  But, I want to restrict the records that are displayed
to
> be based upon certain criteria.  What is the best way to implement this
with
> an existing DBGrid's relationship with a datasource?  Thanks very much in
> advance.

> ....Brad

------=_NextPart_000_01BCE9DA.7DAAF730
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<html><head></head><BODY bgcolor=3D"#FFFFFF"><p><font size=3D2 =
color=3D"#000000" face=3D"Arial">Brad,<br><br>I needed the same =
capability. &nbsp;I have a screen with over 50 checkboxes the user needs =
to select from, then I use a base sequel statement to implement the =
routine.<br><br><font color=3D"#008000">EXAMPLE<font =
color=3D"#000000">:<br><br>data1.Recordset.Requery<br>a =3D =
InputBox(&quot;Please input the Inmate Last name you wish to search =
for:&quot;, &quot;Inmate Last Name record Search&quot;)<br>If a =3D =
&quot;&quot; Then<br> &nbsp;&nbsp;&nbsp;Exit Sub<br> =
&nbsp;&nbsp;&nbsp;End If<br> Screen.MousePointer =3D =
11<br>SelectVariable =3D &quot;[Inmate Last Name]&quot;<br><br>If Check3 =
=3D 1 Then<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SelectVariable =
=3D SelectVariable &amp; &quot;,&quot; &amp; &quot;[First =
Name]&quot;<br> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data1.RecordSource =3D =
&quot;SELECT &quot; &amp; SelectVariable &amp; &quot; from COMPLNTS =
where [Inmate Last Name] like '&quot; &amp; UCase(a) &amp; =
&quot;*';&quot;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End =
If<br>If Check4 =3D 1 Then<br> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SelectVariable =3D =
SelectVariable &amp; &quot;, &quot; &amp; &quot;[Inmate =
Number]&quot;<br> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data1.RecordSource =3D =
&quot;SELECT &quot; &amp; SelectVariable &amp; &quot; from COMPLNTS =
where [Inmate Last Name] like '&quot; &amp; UCase(a) &amp; =
&quot;*';&quot;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End =
If<br>If Check5 =3D 1 Then<br> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SelectVariable =3D =
SelectVariable &amp; &quot;, &quot; &amp; &quot;[Institution =
Code]&quot;<br> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data1.RecordSource =3D =
&quot;SELECT &quot; &amp; SelectVariable &amp; &quot; from COMPLNTS =
where [Inmate Last Name] like '&quot; &amp; UCase(a) &amp; =
&quot;*';&quot;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End =
If<br><br>Data1.refresh<br><br><font color=3D"#008000">END CODE:<font =
color=3D"#000000"><br><br>This works great and not only finds the =
specific records I want but displays ONLY the fields which the user has =
requested. &nbsp;It is also very fast. &nbsp;With a database of over =
500,000 records it takes about 8 seconds to run no matter what =
checkboxes are selected.<br><br>-- <br>Sincerely,<br><br>Todd W. =
Butson<br>Department of Corrections - State of Wisconsin<br>(608) =
261-7118 Voice<br><font =

color=3D"#000000"><br><font =

color=3D"#000000"><br><br><br><br><br>Brad Melendy &lt;<font =

color=3D"#000000">&gt; wrote in article &lt;<font =

ont color=3D"#000000">&gt;...<br>&gt; I want to take a DBGrid and show =
data from a Datasource that points to an<br>&gt; Access Database. =
&nbsp;But, I want to restrict the records that are displayed to<br>&gt; =
be based upon certain criteria. &nbsp;What is the best way to implement =
this with<br>&gt; an existing DBGrid's relationship with a datasource? =
&nbsp;Thanks very much in<br>&gt; advance.<br>&gt; <br>&gt; =
....Brad<br>&gt; <br>&gt; <br>&gt; <br>&gt; <br>&gt; </p>
</font></font></font></font></font></font></font></font></font></font></f=
ont></font></font></body></html>
------=_NextPart_000_01BCE9DA.7DAAF730--



Fri, 28 Apr 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. dropdownlists and grids, which ways is the best?

2. good ways to use recordsets without autocommit?

3. Better ways to schedule?

4. good ways to use recordsets without autocommit?

5. Better ways to put text into textbox??

6. DBGrid - Drag and drop data from one DBGrid to another DBGrid

7. Using Where Clause with Date to restrict rows in a DBGrid control

8. effiecient ways of data access

9. Sending data both ways with MS Winsock control

10. APEX True DBGrid vs. Sheridan DATA WIDGETS DBGrid

11. HELP DBGrid: Controling data in and size of Columns in DBGrid

12. APEX True DBGrid vs. Sheridan DATA WIDGETS DBGrid

 

 
Powered by phpBB® Forum Software