You could mimic it using the textbox's On Key Down event:
Code:
If KeyCode = 9 And Shift = 0 Then
Dim intSelStart As Long
' nullify
KeyCode = 0
intSelStart = Me.[COLOR=Red]MemoTextbox[/COLOR].SelStart
' pad
If IsNull(Me.[COLOR=Red]MemoTextbox[/COLOR]) Then
Me.[COLOR=Red]MemoTextbox[/COLOR].Value = " "
Else
Me.[COLOR=Red]MemoTextbox[/COLOR].SelText = " "
End If
' set the insertion point
Me.[COLOR=Red]MemoTextbox[/COLOR].SelStart = intSelStart + 4
End If
Substitute MemoTextbox for the name of the memo textbox (as the name implies).
Thanks for the reply. I get the gist of it and the solution could be of value to me, but I cannot get it to work. If the field is blank (null), then the first tab works but thereafter no tabs are created. If the field has something in it to start with then again no tabs are produced. I have included some message boxes in the code to obtain the variable values at various points and they seem sensible. Perhaps you could point to areas that could be investigated further.
If KeyCode = 9 And Shift = 0 Then
Dim intSelStart As Long
' nullify
KeyCode = 0
With Me.[COLOR=Red]MemoTextbox[/COLOR]
intSelStart = .SelStart
' pad
If Len(.Value) = .SelLength Then
.Value = " "
Else
.Value = Mid(.Text, 1, .SelStart) & " " & _
Mid(.Text, .SelStart + .SelLength + 1)
End If
' set the insertion point
.SelStart = intSelStart + 4
End With
End If
Thanks for the revised code - this works well for me.
As a matter of possible interest, what started this enquiry was as follows. I have a database that allows for special conditions to be added to an order as a series of memo text fields as separate records. These are normally completed via a form, but in one instance the operator cut and pasted a special condition from a WORD document that included a number of "tabs". When the contract was printed it was noticed that all the tabs that had been inserted in WORD had disappeared. Although the text had been closed up, it still made sense. However, the system allows for a contract to be output as a PDF attachment to an e-mail, in which case the text on the PDF was completely un-intelligible where embedded tabs existed (Over printing etc.). As a test I cut and pasted the text back from the database to WORD and the tabs all re-appeared. Producing a PDF of this word doc gives a correct result. Is this problem due to the handling by PDF of data from an access database? Your comments would be welcome.