Special character in text column

A

Alan T

I have a column defined as text field in MS Access 2003.
I want to insert a string with prefixed of hex02, followed by Carriage
Return, followed by Line Feed and ended with hex03.

How do I do that manually?
eg.
(hex02 character)....This is a test.....(Carriage Return, Line Feed, hex03)

Thanks
 
A

Alan T

Sorry, I mean how do I manually enter the string with the special characters
by :
Run MS Access
Open the table in data view
Goto the record field
Enter it
 
J

John W. Vinson

Sorry, I mean how do I manually enter the string with the special characters
by :

Not sure it will work - those are not in the valid ASCII range - but try this:
hold down the Alt key and enter

002

or

003

on the numeric keypad. It might instead be necessary to just use 02 and 03.


John W. Vinson [MVP]
 
D

Douglas J. Steele

John W. Vinson said:
Not sure it will work - those are not in the valid ASCII range - but try
this:
hold down the Alt key and enter

002

or

003

on the numeric keypad. It might instead be necessary to just use 02 and
03.

And sorry if I'm stating the obvious, but you must use the numeric keypad
(not the numbers at the top of the keyboard), and NumLuck must be on.
 
C

Casteele/ShadowLord

(Sorry if this posts twice.. Web based readers are PitA's!)

As far as I have ever experienced, you cannot directly enter any control
codes (ASCII codes 0-31 decimal / 0x00-0x1F hex (or &H00-&H1F for the VB
purists ;-))) directly from the keyboard, not even using the ALT+0nnn trick
on the numeric keyboard. Think of it like the ALT key on many keyboards; The
ALT key is a modifier key that changes how the keyboard operates _or_ how the
program interprets the following keystrokes. The control key and any control
codes it helps generate are much the same. The only real difference is that
when ASCII was first designed, the control codes were assigned a block of
ASCII codes so they could be transmitted over the data link to control the
recieving end. There was no intention at that time that such codes would ever
be *part* of the data stream, so there was little reason that teletypes,
computers, etc, needed to directly enter the codes. Sorry if I'm not being
very clear about that all, I'm trying not to give a long technical
explaination.. Just enough to understand why you cannot.

What you can do, however, is write some code (VBA can do it, not sure about
macros) which can either insert such codes directly as part of their
processing, or you can write a conversion routine and assign it to an
input/edit event (I'm not entirely sure how to do this in VBA, I only know it
_can_ be done.) Typically, you'd have such a routine scan through the string
and find special sequences, called "escape sequences", like "\x03" (many
programming and scripting language use such escape sequences for special
codes) and convert them into the proper bytes before storing it in your
database.

Alternatively, you can store the data "as-is" (meaning, if you type "\x03"
into the field, it's stored as the text string "\x03", not as the hex code
0x03) directly in the database, and do the conversion only when you extract
the data.

Each method has it's pro's and con's, and which is best depends on what you
plan to do with it.

HTH,
C.
 
J

John W. Vinson

As far as I have ever experienced, you cannot directly enter any control
codes (ASCII codes 0-31 decimal / 0x00-0x1F hex (or &H00-&H1F for the VB
purists ;-))) directly from the keyboard, not even using the ALT+0nnn trick
on the numeric keyboard.

Thanks, Casteele. After I posted (should have done it before!!!) I tried
several variants and it appears that you're right - you cannot enter x'02'
from the keyboard using that technique, or perhaps at all.

John W. Vinson [MVP]
 
A

Alan T

Or I get around by this:
I have a sample file contains text strings have these Hex02 and Hex03
characters.
If I open this text file by a text editor like NotePad or UltraEdit. Then
Copy(Ctl+C) the text string and paste(Ctl+V) into the text column. Does MS
Access 2003 preserve these 2 characters?
 
J

John W. Vinson

Or I get around by this:
I have a sample file contains text strings have these Hex02 and Hex03
characters.
If I open this text file by a text editor like NotePad or UltraEdit. Then
Copy(Ctl+C) the text string and paste(Ctl+V) into the text column. Does MS
Access 2003 preserve these 2 characters?

I don't know... let's try it...

x02:
x03:


Shows up as a rectangular box (in UltraEdit, Access and Agent); not sure what
you'll see there.


John W. Vinson [MVP]
 
J

John W. Vinson

I don't know... let's try it...

x02:
x03:


Shows up as a rectangular box (in UltraEdit, Access and Agent); not sure what
you'll see there.

Curious. The journey from Agent to the newsgroup and back has changed the
x'02' to x'3A', a colon.

John W. Vinson [MVP]
 
A

Alan T

To make it complicated.
How do I append Carriage Return character and Line Feed character at the end
of line?
 
J

John W. Vinson

To make it complicated.
How do I append Carriage Return character and Line Feed character at the end
of line?

That's *really* easy. Ctrl-Enter; or set the textbox's Enter Key Behavior
property to New Line.

In code, append Chr(13) & Chr(10) or vbCrLf to the text.

Much easier than the nonstandard x'02' and x'03' characters!

John W. Vinson [MVP]
 
A

Alan T

Hi,
I tried this in the very first beginning of my problem but it seemed did not
work.

eg. I entered Goodbye and Ctrl-Enter in the MSAccess table.

I copied the string to a text file and wrote a small application to read the
string out.
The application display character one by one, there were only 7 characters.
 
J

John W. Vinson

Hi,
I tried this in the very first beginning of my problem but it seemed did not
work.

eg. I entered Goodbye and Ctrl-Enter in the MSAccess table.

I copied the string to a text file and wrote a small application to read the
string out.
The application display character one by one, there were only 7 characters.

VERY odd. Ok, I tried it in one of my tables, and of course you're right.

If you type Ctrl-Enter and then any printing character - not a blank it seems
- it gets trimmed off (just as a trailing blank will get trimmed off).

I was not aware of that.

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top