Tabs in a memo control (1 Viewer)

S

Registered User.
Local time
Today, 15:22
Joined
Feb 17, 2000
Messages
33
I need to use a memo to store variable text depending on users works; is it possible to enable the "Tab" key not for activate the next control but for tex spacing ? (like a grid or a table in a word procesor)
Sorry for my english
Thank you in advance
 

Travis

Registered User.
Local time
Today, 07:22
Joined
Dec 17, 1999
Messages
1,332
To make the Tab Key work the way you would like you will need to trap for it.

Here is some code:

Private Sub Text0_KeyDown(KeyCode As Integer, Shift As Integer)
Dim stFront As String
Dim stBack As String
Dim lPos As Long
If KeyCode = 9 and Shift = 0 Then
KeyCode = 0
lPos = Text0.SelStart
stFront = Left(Text0.Text, lPos)
stBack = Mid(Text0.Text, lPos + 1)
Text0.Text = stFront & Space(5) & IIf(Trim(stFront) = "", ".", "") & stBack
Text0.SelStart = lPos + 5
if trim(stFront) = "" then SendKeys "{del}"
End If
End Sub

First I use the Keydown Event of the Control. Next I check to see if KeyCode = 9 and Shift = 0 (TAB) don't want to trap Shift+Tab. I then set the KeyCode = 0 (or cancel the keystroke). I use the SelStart property to determine were I am in the control (the User maybe in the middle when they press the Tab key). I seperate out the stuff prior to the Tab location and After the Tab location. I then add 5 spaces in between the two halves. Notice the IIF statement and the If Statement. These are only used if there is no text in front of the Tab Location. Access truncates these for some reason. So I add a "." and then delete it (the user wont see this it happens to fast)
 

S

Registered User.
Local time
Today, 15:22
Joined
Feb 17, 2000
Messages
33
It works, you are great: I'll call the new form "Travis"
Thanks a lot
 

Travis

Registered User.
Local time
Today, 07:22
Joined
Dec 17, 1999
Messages
1,332
Your Welcome

By the way I'm flattered.
 

accesswatcher

New member
Local time
Today, 14:22
Joined
Jan 14, 2000
Messages
9
I have the same need for tabs in Memo fields..I have use Access 97, but not too familiar with codes.. Please explain how to use this code. Thanks in Advance.
 

S

Registered User.
Local time
Today, 15:22
Joined
Feb 17, 2000
Messages
33
In the event properties of yuor memo control (called Text0) simply report the example (Copy / paste) and join it
PS: you better don't copy the first (Private ...) and the last instruction (end sub)
Bye
 

Users who are viewing this thread

Top Bottom