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

Can't get a tab character 3

Status
Not open for further replies.

GBall

Programmer
May 23, 2001
193
GB
Hi,
I'm trying to output a tab separeted piece of data like so.

Dim strSeparator As String

strSeparator = Chr$(9)
strCSV = strCSV & """" & Me(i).Value & """" & strSeparator

but all I'm getting is 4 spaces and a carriage control, linefeed.
Even if I do ?chr(9) in the debug window I get the same.
Anyone know why this should be ?


Regards,
Graham
 
Not sure if this will help in your situation...

You could try using the built in constants for tab, line feed etc.

vbTab (tab)
vbLf (line feed)
vbCrLf (carriage return, line feed)

Instead of chr$



There are two ways to write error-free programs; only the third one works.
 
That does the same thing.
Ami I missing something here ?
Is there a setting in 2000 that turns tabs into spaces or something ?

Regards,
Graham
 
Where are you outputting the data to? Is it straight to a file or into a table first?



There are two ways to write error-free programs; only the third one works.
 
I'm building a string variable to populate a memo filed, which then gets included in an email.

Regards,
Graham
 
I've just used the following string to insert a record, and it is inserting a tab character...

strSQL = "INSERT INTO tblMemo (fldMemo) VALUES ('" & txtMemo & vbTab & txtMemo & "')"

Building the string first also works...

strString = txtMemo & vbTab & txtMemo

strSQL = "INSERT INTO tblMemo (fldMemo) VALUES ('" & strString & "')"

There are two ways to write error-free programs; only the third one works.
 
How do you know it's working ?
Not being funny, but I pasted the code into Word and revealed the formatting codes and tried searching for a tab character - didn't work.
I also saved the string to a file and opened it in a hex editor and got 202020200D0A - from ?chr(9) in debug.

Are you using Access 2000 ?

This is driving me nuts - such a simple requirement!!

Regards,
Graham
 
The crlf was probably added with the ?
So how is it that Word couldn't find a tab character ?
This string will be decoded by some other software after being sent to a client.
Will it work OK?

Thanks for your help.

Regards,
Graham
 
I know it's working because I can see the control code in field (also I've used this before for outputting to text files).
How do you know yours isn't working? Depends on what you use to view the resulting string...


There are two ways to write error-free programs; only the third one works.
 
Word can't find it, neither could another text editor I use, which has the option to search for a tab character.

Regards,
Graham
 
I'm using Access 97, I've just copied and pasted mine into word and the control char is definately there...





There are two ways to write error-free programs; only the third one works.
 
Ok guys, thanks for your help.
I'm gonna take a leap of faith, trust Microsoft (what am I saying ?) and see if anyone has trouble with it.
Thanks again.

Regards,
Graham
 
Best of luck...

[thumbsup]

There are two ways to write error-free programs; only the third one works.
 
Sorry, me again.
Thought I'd just give it another shot.
I created the formatted string below using the code below (roughly).
I opened Notepad and saved it into a txt file, then went into Access to import the file into a new table.
Every step of the way, I told Access that it was a tab delimited file.
But, when it came to defining the fields, Access took the whole string as one field - it didn't recognise it's own tabs !!!!

strSeparator = Chr$(9)
intcnt = Me.Count
For i = 0 To intcnt - 1
If Me(i).Visible = True Then
Select Case Me(i).ControlType
Case acTextBox:
strCSV_Text = strCSV_Text & """" & Me(i).Value & """" & strSeparator
End Select
End If
Next i


?strcsv_text gives me this
"d" "d" "d" "d" "d" "d" "d" "d" "d" "d" "d" "d" "" "" ""


Cheers.


Regards,
Graham
 
I have this...

Private Sub cmdSave_Click()
Dim db As Database
Dim strSQL As String
Dim strString As String
Dim intCount As Integer

'Add the value of txtMemo 5 times with tab inbetween
'to strString
For intCount = 1 To 5
strString = strString & """" & txtMemo & """" & vbTab
Next intCount

'Insert into memo field in table tblMemo
strSQL = "INSERT INTO tblMemo (fldMemo) VALUES ('" & strString & "')"

Set db = CurrentDb

db.Execute (strSQL)

End Sub

If I copy and paste the data out of this field into word and show the the non printing chars, I get tabs in all the right places????



There are two ways to write error-free programs; only the third one works.
 
My mate's just tried the same piec of code in 97....and he gets tabs !!!!
Must something with Access 2000.
I was just developing a couple of routines during slack time at work, lets hope we never have to upgrade.
thanks again.

Regards,
Graham
 
Just a thought...

Have you compiled the project? Any errors?
Since I also get the tabs in their place, I suspect this is the beginning of some code corruption, so you'd better watch out while you can.

Try the decompile switch:

Start - Run

msaccess.exe /decompile "C:\Path\YourFile.mdb"

Needless to say, make a back-up copy first.

Good luck

[pipe]
Daniel Vlas
Systems Consultant

 
No problems there !
I assume you also have A2K ?
Could I email you my mdb and see if it's a system problem ?
It's only 30k zipped.

Regards,
Graham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top