+ Reply to Thread
Results 1 to 3 of 3

Please help... Deadline (ADO recordset.filter)

Hybrid View

  1. #1
    Registered User
    Join Date
    08-25-2004
    Posts
    82

    Please help... Deadline (ADO recordset.filter)

    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..

            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!

  2. #2
    Dove
    Guest

    Re: 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" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > 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
    >




  3. #3
    Tim Williams
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    >
    > 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
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1