trailing null characters

T

Tim

Hi

I have fields where the data has trailing null characters, how can I "trim
them away"? In mysql I would use SELECT TRIM(BOTH NULL FROM FieldName) ...

I don't know in Access wich is the syntax.

Tim.
 
R

Rick Brandt

Tim said:
Hi

I have fields where the data has trailing null characters, how can I "trim
them away"? In mysql I would use SELECT TRIM(BOTH NULL FROM FieldName) ....

I don't know in Access wich is the syntax.

Trim([FieldName])
 
T

Tim

Trim removes blanks, but it doesn't remove my null chars :-(


Rick Brandt said:
Tim said:
Hi

I have fields where the data has trailing null characters, how can I "trim
them away"? In mysql I would use SELECT TRIM(BOTH NULL FROM FieldName) ...

I don't know in Access wich is the syntax.

Trim([FieldName])
 
B

Bill Crawford

HI:

A null is a blank

what characters do you see?


Tim said:
Trim removes blanks, but it doesn't remove my null chars :-(


Rick Brandt said:
Tim said:
Hi

I have fields where the data has trailing null characters, how can I "trim
them away"? In mysql I would use SELECT TRIM(BOTH NULL FROM FieldName) ...

I don't know in Access wich is the syntax.

Trim([FieldName])
 
W

Wayne Morgan

See if this will work.

Trim(Replace([FieldName], vbNullString, ""))

--
Wayne Morgan
MS Access MVP


Tim said:
Trim removes blanks, but it doesn't remove my null chars :-(


Rick Brandt said:
Tim said:
Hi

I have fields where the data has trailing null characters, how can I "trim
them away"? In mysql I would use SELECT TRIM(BOTH NULL FROM FieldName) ...

I don't know in Access wich is the syntax.

Trim([FieldName])
 
R

Rick Brandt

Tim said:
Trim removes blanks, but it doesn't remove my null chars :-(

There is no such thing as a Null character. If there is padding of
"blanks" in the field then they are either spaces or some other
non-printing character. Non-printing characters normally show up as boxes
or vertical bars though.

I suppose if there were non-printing characters (other than spaces) that
were being displayed as blanks that the Trim() function would ignore them,
but I have never heard of that.
 
J

John Spencer (MVP)

I guess that you are getting these fields from a source other than Jet. I think
that to do what you want you are going to have to write a vbfunction to trim the
null characters.

Here is a little sample function to show you the concept

Public Function fMakeStringWithNullCharacters()
Dim strTest As String
Dim lCount As Long


strTest = "ABC"
MsgBox Len(strTest)

strTest = strTest & vbNullChar & String(20, 0)
MsgBox Len(strTest)

For lCount = Len(strTest) To 1 Step -1
If Mid(strTest, lCount, 1) <> vbNullChar Then
strTest = Left(strTest, lCount)
Exit For
End If
Next lCount

MsgBox Len(strTest)
End Function
 

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

Similar Threads


Top