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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODC / Datagrid Filter...

Status
Not open for further replies.

dedo8816

Programmer
Oct 25, 2006
94
GB
Hi, Im using an ADODC control to scroll and save data to an MS Access 2000 DB, i also have a datagrid connected to the ADO which displays the information as i update it.

I would like to add a filter function to the datagrid so that i can filter by the date expected and see only those items which have the date i specify.

Ive tried several different ways of doing this but i never seem to be able to get it to work.

Adodc1.RecordSource = "Select * From Fasttrack Where DateDue = txtdatefilter.text"

Adodc1.Refresh

This does nothing except give me an error message Syntax Error in FROM Clause. Then when i debug it highlights Adodc1.Refresh as the problem. When i take the refresh out it doesnt do anything at all...

Any help will be appreciated
 
You appear to be using the literal string txtdatefilter.text as your filter value. You need the value of the variable instead. Try
Code:
Adodc1.RecordSource = "Select * From Fasttrack Where DateDue = " & txtdatefilter.text

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 

Or better

Adodc1.RecordSource = "Select * From Fasttrack Where DateDue = #" & format(txtdatefilter.text , "yyyy-mm-dd") & "#;"

since it's for MS-Access
 
Never seem to work no matter what i do, thanks for you code but these still do nothing.

I have 7 Text boxes and 1 check box which are all tied to my ADO. My datagrid is tied to my ADO which is connected to an MS Access Database. The table name is called Fasttrack and the field i want to filter is called DateDue.
My date format is dd/mm/yyyy (UK). The criteria for the filter is entered into a text box called txtdatefilter.text.

When i press the letter "t" the date auto fills into the text box and i click the filter button (cmdfilter).

Nothing happens... nothing at all

 
ADO uses single quote as date delimiters

Try:
Code:
Adodc1.RecordSource = "Select * From Fasttrack Where DateDue = '" & txtdatefilter.text & "'"
 
dedo8816

I use ADO to talk to an mdb. The date format is an ANSI seperated format which is unambiguous as PHV has many times stated in these fora, and you should trust it as it is working properly. About pwise 's suggestion I can't tell, since my ADO work is not with the ADODC control at all (I hate that control).Everything with ADO is "hand made"

Maybe you could filter the ADODC.Recordset instead of querring again the table?

Adodc1.RecordSource.Filter = "DateDue = #" & format(txtdatefilter.text , "yyyy-mm-dd") & "#
 
er...

Adodc1.RecordSet.Filter = [etc]

surely?

This is the way I would do it, too. No sense making unnecessary round trips to the data source.

Dedo, I would try this. If it doesn't work, post your code so we can have a look at it.
 
Bob, thanks. I should have replied to this ages ago but i saw the error with the recordsource bit.
I have it all working now thanks to everyone suggestions here. Lets hope ive learned this for the future so i dont keep asking silly questions :)

Thanks everyone
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top