Welcome to SPN

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

Sign Up Now!

SQL String continuation in VB

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

  1. wnfisba

    wnfisba
    Expand Collapse
    Guest

    I have this SQLString in a VB Module within Access. How do I make it so it is
    readable and syntaxcally correct???

    SQLString = "SELECT RTRIM(LTRIM(GEN.sale_number)) AS sale_number,
    RTRIM(LTRIM(GEN.borrow_ln)) AS borrow_ln,
    RTRIM(LTRIM(GEN.borrow_ssn)) AS borrow_ssn,
    RTRIM(LTRIM(GEN.loan_num)) AS loan_num,
    CASE WHEN DEFAULTS.short_name LIKE 'DIR%'
    THEN 'RETAIL'
    WHEN DEFAULTS.short_name = 'WHL01 - MD'
    THEN 'WHL01 - PA'
    WHEN DEFAULTS.short_name = 'WHL01 - NE'
    THEN 'WHL01 - PA'
    WHEN DEFAULTS.short_name = 'WHL01 - NY'
    THEN 'WHL01 - PA'
    WHEN DEFAULTS.short_name = 'WHL04 - C2'
    THEN 'WHL04 - CA'
    Else: DEFAULTS.short_name
    End 'short_name',
    RTRIM(LTRIM(USERINFO.last_name)) AS last_name,
    RTRIM(LTRIM(GEN.prop_state)) AS prop_state,
    RTRIM(LTRIM(GEN.prop_zip)) AS prop_zip,
     
  2. Loading...

    Similar Threads Forum Date
    Microsoft Brings 64-Bit Perks in SQL Server 2000 Service Pack (Ziff Davis) Interfaith Dialogues May 7, 2005
    India Akal Takht Chief Wants Obama to Take Stringent Measures to Check Hate Crimes against Sikhs Breaking News Sep 25, 2013
    Preserving Ancient String Instruments Gurmat Sangeet Feb 28, 2011
    Vibrating String Interfaith Dialogues Dec 14, 2007
    Sikh News String of welfare measures for Dalits in Punjab (Outlook India) Breaking News Oct 26, 2007

  3. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    You need to close the string to continue it on the next line in VBA, e.g.:

    SQLString = "SELECT RTRIM(LTRIM(GEN.sale_number)) AS sale_number, " & _
    "RTRIM(LTRIM(GEN.borrow_ln)) AS borrow_ln, " & _
    "RTRIM(LTRIM(GEN.borrow_ssn)) AS borrow_ssn, " & _
    "...

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "wnfisba" <wnfisba@discussions.microsoft.com> wrote in message
    news:5347DAA5-30C8-4AF6-A72D-E7770A343C3A@microsoft.com...
    >I have this SQLString in a VB Module within Access. How do I make it so it
    >is
    > readable and syntaxcally correct???
    >
    > SQLString = "SELECT RTRIM(LTRIM(GEN.sale_number)) AS sale_number,
    > RTRIM(LTRIM(GEN.borrow_ln)) AS borrow_ln,
    > RTRIM(LTRIM(GEN.borrow_ssn)) AS borrow_ssn,
    > RTRIM(LTRIM(GEN.loan_num)) AS loan_num,
    > CASE WHEN DEFAULTS.short_name LIKE 'DIR%'
    > THEN 'RETAIL'
    > WHEN DEFAULTS.short_name = 'WHL01 - MD'
    > THEN 'WHL01 - PA'
    > WHEN DEFAULTS.short_name = 'WHL01 - NE'
    > THEN 'WHL01 - PA'
    > WHEN DEFAULTS.short_name = 'WHL01 - NY'
    > THEN 'WHL01 - PA'
    > WHEN DEFAULTS.short_name = 'WHL04 - C2'
    > THEN 'WHL04 - CA'
    > Else: DEFAULTS.short_name
    > End 'short_name',
    > RTRIM(LTRIM(USERINFO.last_name)) AS last_name,
    > RTRIM(LTRIM(GEN.prop_state)) AS prop_state,
    > RTRIM(LTRIM(GEN.prop_zip)) AS prop_zip,
     

Share This Page