![]() |
Please help... Deadline (ADO recordset.filter)
Hey everyone, thanks for your help, im in a bind and need a littl help... I am trying to search a database with excel and find out if record is blank with recordset.filter... here is my code.. Code ------------------- rstTemp.Filter = "CityDataID=' " & strFilter & "' And Year=' ""' And Month=' ""' ------------------- Pretty much i want it to find a primary key (CityDataID) and if it doe find it see if the recors for Year and Month are blank. I cant seem t get this code to work... Any ideas? I would be very grateful Thanks -- greenfalco ----------------------------------------------------------------------- greenfalcon's Profile: http://www.excelforum.com/member.php...fo&userid=1362 View this thread: http://www.excelforum.com/showthread.php?threadid=56034 |
Please help... Deadline (ADO recordset.filter)
Not sure how to do it with a filter like that, but using traditional SQL
with a recordset object: -------------------------- Dim string_variable as String Dim No_CityDataID as Boolean Dim No_Month as Boolean Dim No_Year as Boolean Dim Duplicate_Key as Boolean ' Dim and Define your recordset/connection here rstTemp.Source = "SELECT * FROM [YourTableName] WHERE CityDataID = '" + string_variable + "'" rst.Open If rstTemp.EOF Then No_CityDataID = True Goto SkipMe ' Without the Goto you will get an error on the move next... ElseIf rstTemp!Year = "" Then ' or Null, depending how how the database handles empty data No_Year = True ElseIf rstTemp!Month = "" Then No_Month = True End If rstTemp.MoveNext 'Optional Primary Key Check If Not rst.EOF Duplicate_Key = True End If SkipMe: rstTemp.Close ------------------------------------------- Substitue the Boolean variables with what you want to do when those situations occur, and make sure to change [YourTableName] to whatever the table's name is in the database. David "greenfalcon" wrote in message ... Hey everyone, thanks for your help, im in a bind and need a little help... I am trying to search a database with excel and find out if a record is blank with recordset.filter... here is my code.. Code: -------------------- rstTemp.Filter = "CityDataID=' " & strFilter & "' And Year=' ""' And Month=' ""'" -------------------- Pretty much i want it to find a primary key (CityDataID) and if it does find it see if the recors for Year and Month are blank. I cant seem to get this code to work... Any ideas? I would be very grateful Thanks! -- greenfalcon ------------------------------------------------------------------------ greenfalcon's Profile: http://www.excelforum.com/member.php...o&userid=13622 View this thread: http://www.excelforum.com/showthread...hreadid=560347 |
Please help... Deadline (ADO recordset.filter)
You seem to have extra spaces in a few places (substituted below with *)
rstTemp.Filter = "CityDataID='*" & strFilter & "' And Year='*""' And Month='*""'" Tim -- Tim Williams Palo Alto, CA "greenfalcon" wrote in message ... Hey everyone, thanks for your help, im in a bind and need a little help... I am trying to search a database with excel and find out if a record is blank with recordset.filter... here is my code.. Code: -------------------- rstTemp.Filter = "CityDataID=' " & strFilter & "' And Year=' ""' And Month=' ""'" -------------------- Pretty much i want it to find a primary key (CityDataID) and if it does find it see if the recors for Year and Month are blank. I cant seem to get this code to work... Any ideas? I would be very grateful Thanks! -- greenfalcon ------------------------------------------------------------------------ greenfalcon's Profile: http://www.excelforum.com/member.php...o&userid=13622 View this thread: http://www.excelforum.com/showthread...hreadid=560347 |
All times are GMT +1. The time now is 10:47 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com