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!

How to use VB6 to view only selected records? 1

Status
Not open for further replies.

THOMASNG

Technical User
May 3, 2002
254
US
I'm using VB6 and ADODC to manipulate an ACCCESS 2000
database. From time to time, I wish to check the database
for old data.
As the database may range up to 30,000, I'd like to
see only those that have the same (OwnerCode & SerialNumber)
or have LatestScan < a certain date. OwnerCode & SerialNumber are already contiguous fields in the database,
and LatestScan is already a field in my database.
 
Use a SQL string with a WHERE clause to select only records matching a certain criteria. Or, if you already have the full set in a recordset, use the .FILTER property. BlackburnKL
 
I would use your current recordsource sql as strOldDataSQL but add a where clause like:

strOldDataSQL = strCurrentSQL & _
&quot; where (OwnerCode = &quot; & Something & _
& &quot; and SerialNumber = &quot; & SomethingElse & &quot;)&quot; & _
&quot; or LatestScan < &quot; & ACertainDate

if chkForOldData.value = vbchecked then
Adodc1.RecordSource = strOldDataSQL
else
Adodc1.RecordSource = strCurrentSQL
end if
 
Do you have a copy of SQL Books On Line? That will give you what you need.

I believe that I have pointed you to this before, but in case you've mislaid it:
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Try creating a query for it in Access and then you can copy it and generalize it in your VB code.

I realize that my last answer was vague. Sorry about that. I was trying to give you enough information that you could fish for more specific direction on the subject (maybe like through a key word search). I didn't have time to write all of the code for you. BlackburnKL
 
I'm having trouble triggering a query (SQL query?) off
of the VB6 event of clicking on a button (Cmd_FindMatchingRecords_Click).
 
Rightclick the ADODC, select the Recordsource tab and select 1 - AdCmdText.

Build your strSQL query as above then in your click event use:

Adodc1.RecordSource = strSQl
Adodc1.Refresh
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
John's answer was the clearest one. Have a star!
My manager has decided to have the query done by the
second computer (not the one with ADODC and VB6). (Gee,
thanks.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top