Results 1 to 4 of 4
  1. #1
    texaschili is offline Novice
    Windows 7 64bit Access 2000
    Join Date
    Dec 2010
    Posts
    2

    How would this access code work as a pass through query?

    I have an If statement and also I need to adjust these dates but when I convert the query to a pass thru it doesn't understand the code.



    Code:
    IIf(tblCustomersBilling!RecordID Is Null,"",CLng(tblCustomersBilling!RecordID)) AS CBRID, IIf(Right(Left(tblCustomers!DateRx,2),1) Like "/",Left(tblCustomers!DateRx,2),Left(tblCustomers!DateRx,2)+"/")+Right(tblCustomers!DateRx,4) AS MnthYrRXFl1

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Pass through to what? SQL Server wouldn't understand it, as it has no IIf() function. The usual replacement for that in a pass through query is a CASE statement. I don't think it will recognize the CLng() function either; you'd use CAST or CONVERT for that.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    texaschili is offline Novice
    Windows 7 64bit Access 2000
    Join Date
    Dec 2010
    Posts
    2
    Quote Originally Posted by pbaldy View Post
    Pass through to what? SQL Server wouldn't understand it, as it has no IIf() function. The usual replacement for that in a pass through query is a CASE statement. I don't think it will recognize the CLng() function either; you'd use CAST or CONVERT for that.
    Ok. Would this work:

    Code:
      CASE tblCustomersBilling.RecordID WHEN IS NULL
                  THEN CAST tblCustomersBilling.RecordID AS CBRID

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    The syntax for the CAST:

    http://msdn.microsoft.com/en-us/libr...sql.80%29.aspx

    and CASE:

    http://msdn.microsoft.com/en-us/libr...SQL.80%29.aspx

    The "searched" syntax is typically used to replace the IIf():

    CASE WHEN tblCustomersBilling.RecordID IS NULL THEN...

    Note that in Access you can use the Nz() function to replace Null values; the SQL Server equivalent is the ISNULL() function.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. !!!!Urgent!!!! Search code doesn't work!
    By Laetilae in forum Programming
    Replies: 4
    Last Post: 12-13-2010, 10:34 PM
  2. Code does not work in 64 Bit Access 2010
    By mwolfod in forum Programming
    Replies: 26
    Last Post: 12-12-2010, 04:39 PM
  3. Replies: 3
    Last Post: 11-26-2010, 12:38 PM
  4. Query doesn't work when launched by code
    By stephenaa5 in forum Queries
    Replies: 1
    Last Post: 10-24-2009, 09:52 AM
  5. VBA Code To Work With MySQL
    By botts121 in forum Programming
    Replies: 0
    Last Post: 07-08-2009, 08:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums