Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why isn't my vbcr working? 2

Status
Not open for further replies.

Cloonalt

Programmer
Jan 4, 2003
354
US
I want a line break in the middle of this string. Can I do that? Maybe my syntax is wrong - it's just ignoring my vbcr.

Any help appreciated.

strSQL = "SELECT 'Matter Comments: ' + ISNULL(matter.mdesc2, '') + ' ' + " & _
"ISNULL(matter.mdesc3, '') + " & vbCr & " + 'Client Comments: ' + ISNULL(client.clname2, '') " & _
"AS Comments FROM matter INNER JOIN client ON matter.mclient = client.clnum " & _
"Where mmatter = " & "'" & Matter & "'" & _
"order by mmatter"
 
try this:

Code:
strSQL = "SELECT 'Matter Comments: ' + ISNULL(matter.mdesc2, '') + ' ' + " & _
        "ISNULL(matter.mdesc3, '')  + Char(10)+Char(13) +  'Client Comments: ' + ISNULL(client.clname2, '') " & _
        "AS Comments FROM matter INNER JOIN client ON matter.mclient = client.clnum " & _
        "Where mmatter = " & "'" & Matter & "'" & _
        "order by mmatter"

-DNG
 

Hi,

use vblf

Here is your evaluated string. What are you doing? Does not make sense summing what seen to be strings.
[tt]
"SELECT 'Matter Comments: ' + ISNULL(matter.mdesc2, '') + ' ' + ISNULL(matter.mdesc3, '') +
+ 'Client Comments: ' + ISNULL(client.clname2, '') AS Comments FROM matter INNER JOIN client ON matter.mclient = client.clnum Where mmatter = ''order by mmatter"
[/tt]


[tt][highlight blue][white]
~ ~
[/white][/highlight][highlight red][white] To be ~[/white][/highlight][highlight blue][white]
~ BE ~
[/white][/highlight][highlight white][blue] safe on the 4th ~[/blue][/highlight][highlight blue][white]
~ ADVISED ~
[/white][/highlight][highlight red][white] Don't ~[/white][/highlight][highlight blue][white]
~ ~
[/white][/highlight][highlight white][blue] get a ~[/blue][/highlight]
[highlight red][white] 5th on the 3rd ~[/white][/highlight]
[highlight white][blue] Or you might not ~[/blue][/highlight]
[highlight red][white] Come 4th on the 5th 4thwith ~[/white][/highlight]
[/tt]


Skip,

[glasses] [red][/red]
[tongue]
 
change:

[tt]
strSQL = "SELECT 'Matter Comments: ' + ISNULL(matter.mdesc2, '') + ' ' + " & _
"ISNULL(matter.mdesc3, '') + [blue]" & vbCr & " + [/blue] 'Client Comments: ' + ISNULL(client.clname2, '') " & _
"AS Comments FROM matter INNER JOIN client ON matter.mclient = client.clnum " & _
"Where mmatter = " & "'" & Matter & "'" & _
"order by mmatter"
[/tt]

To:

Code:
strSQL = "SELECT 'Matter Comments: ' + ISNULL(matter.mdesc2, '') + ' ' + " & _
        "ISNULL(matter.mdesc3, '')  + [!]Char(13) + char(10) + [/!] 'Client Comments: ' + ISNULL(client.clname2, '') " & _
        "AS Comments FROM matter INNER JOIN client ON matter.mclient = client.clnum " & _
        "Where mmatter = " & "'" & Matter & "'" & _
        "order by mmatter"

By doing it this way, SQL Server server will add the cr lf for your (using their ascii values). If you test this in Query Analyzer, you won't see the seperate lines because QA always 'chops' them off.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Correction: Query Analyzer ignores cr's and lf's when displaying in grid mode. By showing the results in text mode, you will see the cr lf's.

Here's how...

Code:
Select 'Line 1:' + Char(13) + Char(10) + 'Line 2:'

Copy/paste to QA. press F5. If you're in grid mode (which is the default), you'll see:

[!]Line 1: Line 2:[/!]

Now, right click in the window, select Results In Text and run again. Now you'll see:

[tt][blue]
----------------
Line 1:
Line 2:

(1 row(s) affected)[/blue][/tt]


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top