Query with non-blank records - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Query with non-blank records

Last post 01-04-2008 04:59 PM by Greg Collins. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 01-02-2008 02:12 PM

    Query with non-blank records

    How do I pull the records that have values?

    In Access, I can do:

    SELECT * FROM ABC WHERE ((Not (ABC.Comments)="blank"));

    This SQL Command will give me all records that have values in Comments field. How do I make it work via Infopath?

    Thanks.

  • 01-02-2008 03:49 PM In reply to

    Re: Query with non-blank records

    You can directly edit the SQL Command in your SQL data connection to add your WHERE clause.

  • 01-03-2008 12:27 PM In reply to

    Re: Query with non-blank records

    Thanks Greg. The method you suggested is a permanent one. However, it is not necessary to be that. I also tried a wildcard query by Microsoft http://support.microsoft.com/kb/826992

    This is the sql command in the above article, but it doesn't do the wildcard function. The query will only work when I give the exact words.
    strMySQLCommand = strMySQLCommand + "([ABC].[Comments] LIKE \"" + strComments + "\")";

    I did a little bit research again, and found out that someone suggested to put "%" and the query works.
    strMySQLCommand = strMySQLCommand + "([ABC].[Comments] LIKE \"%" + strComments + "%\")";
    Howerver, when I type "*" the query returns the comments that contain "*"
    Again, the wildcard is not functioning.

    Pleace advice.

  • 01-04-2008 04:59 PM In reply to

    Re: Query with non-blank records

    Yes, editing the data connection SQL command permanently changes the default query. However, the query command is available to be updated at any time using code before you query.

    When using LIKE, you need to use the "%"s. The LIKE clause *is* your wildcard...

    So if you use:

    SELECT * FROM table WHERE column LIKE '%an%'

    This will select any row where 'column' has the string "an" in it. This is not case-sensitive. Note the use of the single quote character around the "%"s.

    "*" by itself is not a wild card in SQL. But using LIKE with % give you that.

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.