Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1. Monthly (Recurring) Target: $300 :: Achieved: $95
      Become a Supporter    ::   Make a Contribution   

SQL Recordset criteria with a *

Discussion in 'Information Technology' started by Hindsey, Jul 28, 2006.

  1. Hindsey

    Hindsey
    Expand Collapse
    Guest

    Below is my code. I have a form that has a field named [Criteria] and a
    button that when clicked creates a new recordset and sets the form to use the
    recordset:

    Dim rsCodes As ADODB.Recordset
    Set rsCodes = New ADODB.Recordset
    sSQL = "SELECT * FROM tabCodeIncidentType Where [Description] Like
    'Fire*'"
    rsCodes.Open sSQL, CurrentProject.Connection, adOpenKeyset,
    adLockOptimistic

    Set Forms("frmLookupCodes").Recordset = rsCodes

    When I click the button to run this code, all of the records on the form go
    away (I originally opened the form without any criteria and displayed all the
    records. I am wondering what is wrong with my code. If I remove the * after
    'Fire, then it does bring up a record that contains only the word Fire in the
    description field. However, that goes away when the * is put in.

    Any help?
     
  2. Loading...

    Similar Threads Forum Date
    Microsoft Brings 64-Bit Perks in SQL Server 2000 Service Pack (Ziff Davis) Interfaith Dialogues May 7, 2005

  3. Douglas J. Steele

    Douglas J. Steele
    Expand Collapse
    Guest

    * (and ?) only work as wildcard characters with DAO. ADO uses % and _ as
    wildcard characters.

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no e-mails, please!)


    "Hindsey" <Hindsey@discussions.microsoft.com> wrote in message
    news:DCEB5E71-180C-4531-9C87-694CB0DE293E@microsoft.com...
    > Below is my code. I have a form that has a field named [Criteria] and a
    > button that when clicked creates a new recordset and sets the form to use

    the
    > recordset:
    >
    > Dim rsCodes As ADODB.Recordset
    > Set rsCodes = New ADODB.Recordset
    > sSQL = "SELECT * FROM tabCodeIncidentType Where [Description] Like
    > 'Fire*'"
    > rsCodes.Open sSQL, CurrentProject.Connection, adOpenKeyset,
    > adLockOptimistic
    >
    > Set Forms("frmLookupCodes").Recordset = rsCodes
    >
    > When I click the button to run this code, all of the records on the form

    go
    > away (I originally opened the form without any criteria and displayed all

    the
    > records. I am wondering what is wrong with my code. If I remove the *

    after
    > 'Fire, then it does bring up a record that contains only the word Fire in

    the
    > description field. However, that goes away when the * is put in.
    >
    > Any help?
     
  4. Hindsey

    Hindsey
    Expand Collapse
    Guest

    Great - Thanks a lot.

    "Douglas J. Steele" wrote:

    > * (and ?) only work as wildcard characters with DAO. ADO uses % and _ as
    > wildcard characters.
    >
    > --
    > Doug Steele, Microsoft Access MVP
    > http://I.Am/DougSteele
    > (no e-mails, please!)
    >
    >
    > "Hindsey" <Hindsey@discussions.microsoft.com> wrote in message
    > news:DCEB5E71-180C-4531-9C87-694CB0DE293E@microsoft.com...
    > > Below is my code. I have a form that has a field named [Criteria] and a
    > > button that when clicked creates a new recordset and sets the form to use

    > the
    > > recordset:
    > >
    > > Dim rsCodes As ADODB.Recordset
    > > Set rsCodes = New ADODB.Recordset
    > > sSQL = "SELECT * FROM tabCodeIncidentType Where [Description] Like
    > > 'Fire*'"
    > > rsCodes.Open sSQL, CurrentProject.Connection, adOpenKeyset,
    > > adLockOptimistic
    > >
    > > Set Forms("frmLookupCodes").Recordset = rsCodes
    > >
    > > When I click the button to run this code, all of the records on the form

    > go
    > > away (I originally opened the form without any criteria and displayed all

    > the
    > > records. I am wondering what is wrong with my code. If I remove the *

    > after
    > > 'Fire, then it does bring up a record that contains only the word Fire in

    > the
    > > description field. However, that goes away when the * is put in.
    > >
    > > Any help?

    >
    >
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page