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 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,
     
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