CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2002
    Location
    Netherlands
    Posts
    132

    VBA SQL Select (Code included)

    Hi all,

    I have this bit of SQL that I can't get working.

    rst1.Open "SELECT Studenten.* FROM Studenten WHERE (((Studenten.Printen) Is Null) AND ((Studenten.VerzendenNaar) Is S));"

    I know the first part is proper untill ....((Studenten.VerzendenNaar) Is S));" is proper but I can't seem to get the end right. If the field VerzendenNaar in the table Studenten has an S in it I wan't it to select it.
    Pretty please with suggar on top tell me what I am doning wrong. (Probably simple as pie)

    Thank you all and have a nice easter!

    Jasper
    Flying is to throw yourself on the ground and miss

  2. #2
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210
    Code:
    rst1.Open "SELECT Studenten.* FROM Studenten WHERE (((Studenten.Printen) Is Null) AND ((Studenten.VerzendenNaar) ='S'));"
    use is when comparing to null
    use = with numbers , strings

  3. #3
    Join Date
    Nov 2002
    Location
    Netherlands
    Posts
    132
    First of all let me thank you for your time and effort.
    Thank you very much for explaining. Maybe you can telle me something else I have A question about.
    My piece of code is reffering to a table, is it possible to make a selection from a query? I can't seem to get it right.

    Best regards,

    Jasper
    Flying is to throw yourself on the ground and miss

  4. #4
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210
    My piece of code is reffering to a table, is it possible to make a selection from a query? I can't seem to get it right.
    yes you can save a query in access and select from it (query it)
    also in SQL Server you can save a query as a view and select from it.

    if you are using access open a new query .. write your select statement (or use the query builder) then save it..
    in your code you can say :

    Select * from Query1 where ......... etc.

  5. #5
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125
    Or.... use nested Select statements [SQL Server and other "real" DBMS for this, Access has problems with it!]
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  6. #6
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210
    Originally posted by TheCPUWizard
    Or.... use nested Select statements [SQL Server and other "real" DBMS for this, Access has problems with it!]
    yes . nested queries are options..but using views can increase performance and decrease the complexity of the query.

    I also used sub queries in access..not bad till now

  7. #7
    Join Date
    Nov 2002
    Location
    Netherlands
    Posts
    132
    Hello hspc and THECPUWizard,

    Thank you again for your time and effort to answer my question, I had weekend and a day of because of easter so that is why I didn't express my gratitude till now.
    I am on my way again, thank you for your time and effort.

    Best regards,

    Jasper
    Flying is to throw yourself on the ground and miss

  8. #8
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210
    Hello hspc and THECPUWizard,
    Thank you again for your time and effort to answer my question, I had weekend and a day of because of easter so that is why I didn't express my gratitude till now.
    I am on my way again, thank you for your time and effort.

    Best regards,

    Jasper
    you are always welcome

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured