Need to convert "tab" to 5 spaces

  • Thread starter Thread starter Bob Howard
  • Start date Start date
B

Bob Howard

Hi everyone,

I have an unbound form with a particular (unbound) control that gets saved
in a "memo" type field in the database. As the user is typing into that
control, I would like to convert their use of the "tab" key to five
consecutive blank spaces.

Using OnKeyDown event, I can convert it to a single blank space (vbKeySpace)
.... but I cannot do mroe than this (separately, I've handled the condition
of the "tab" keyh being pressed along wiht "alt" or "ctrl" or "shift" ---
these are not issues).

Anyone know of a way to substitute multiple blanks apces for a tab entered
into an unbound text box??

Thanks...

bob
 
Bob Howard said:
Hi everyone,

I have an unbound form with a particular (unbound) control that gets saved
in a "memo" type field in the database. As the user is typing into that
control, I would like to convert their use of the "tab" key to five
consecutive blank spaces.

Using OnKeyDown event, I can convert it to a single blank space
(vbKeySpace) ... but I cannot do mroe than this (separately, I've handled
the condition of the "tab" keyh being pressed along wiht "alt" or "ctrl"
or "shift" --- these are not issues).

Anyone know of a way to substitute multiple blanks apces for a tab entered
into an unbound text box??

Thanks...

bob

The problem is that Access doesn't allow trailing spaces. Try this:

In your KeyDown event, change all tabs to five Chr(0)'s instead of spaces.
Then in the control's BeforeUpdate event, change all Chr(0)'s to spaces (ie
clean up the data before it gets stored).
 
Stuart McCall said:
The problem is that Access doesn't allow trailing spaces. Try this:

In your KeyDown event, change all tabs to five Chr(0)'s instead of spaces.
Then in the control's BeforeUpdate event, change all Chr(0)'s to spaces
(ie clean up the data before it gets stored).

Thanks for the idea, but I don't think this will do the trick. For two
reasons:

First, the matter of trailing blank spaces is only an issue when I would try
to save the data ... which is later in the processing.

Second, and perhaps more meaningful, is that the variable I pass the result
back is defined as an Integer (an Access requirement) and not a string
field. As an Integer, I don't get to pass back multiple values of
anything...

bob
 
Bob Howard said:
Thanks for the idea, but I don't think this will do the trick. For two
reasons:

First, the matter of trailing blank spaces is only an issue when I would
try to save the data ... which is later in the processing.

Second, and perhaps more meaningful, is that the variable I pass the
result back is defined as an Integer (an Access requirement) and not a
string field. As an Integer, I don't get to pass back multiple values of
anything...

bob

I was thinking you could do something like the following in your KeyDown
event:

If KeyCode = 9 Then
MemoControl.Value = MemoControl.Value & String(5, 0)
KeyCode = 0
End If
 
....snip
I was thinking you could do something like the following in your KeyDown
event:

If KeyCode = 9 Then
MemoControl.Value = MemoControl.Value & String(5, 0)
KeyCode = 0
End If

Your solution (above) does add the blanks, but always at the end. I guess I
wanted them to be inserted where the cursor was pointing.

I searched for a solution, and believe I've found it from Allen Browne at
this url...

http://www.everythingaccess.com/tut...A-to-insert-characters-at-the-cursor-position

Thanks...

bob
 
Back
Top