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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Print on the same line 1

Status
Not open for further replies.

pelagic

Programmer
Nov 7, 2002
97
US
Hi there,

I have the following tableA with data
Column1 Column2 Column3
How are you?
I am fine.

My goal is to convert this into a insert stament such as
INSERT INTO tableB (Column1, Column2, Column3)
VALUES ('How', 'are', 'you?');

INSERT INTO tableB (Column1, Column2, Column3)
VALUES ('I', 'am', 'fine?');

Here is the code.
All the dim statements and open file here.
I have this part working now.

'open file for writting
Open FileTex for Output as FileNo
Do While not rs.EOF
Print #FileNo, "INSERT INTO tableB ( "
For i = 0 To FieldCount
Print #FileNo, rs.Fields(i).Name & ", "

Print #FileNo, "VALUES " & "(" & rs.Fields(i).value & ", "
Next i
loop

This code displays the following:
INSERT INTO tableB(
Column1,
Column2,
Column3,

How could I display this in the same line with the close ")"?
I like to display in the same line for the INSERT statement and VALUES statement.

Thank you for your help.




 
Try:
Code:
If i = FieldCount Then
   Print #FileNo, rs.Fields(i).Name & ") "
Else
   Print #FileNo, rs.Fields(i).Name & ", "
End If
djj
 
Hi djj55,

Thank you very much for your help.
Your code does print the close ")" on the same line, however the "INSERT INTO" is still on the separate line.

Again thank you.

pelagic
 
Putting a semicolon at the end of the Print# statement will write the line without a CRLF.

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top