Code or other method to insert blank characters?

Mist

Registered User.
Local time
Today, 09:49
Joined
Mar 5, 2012
Messages
66
I wish to have some code, or something else, that will read the user’s input and insert spaces between the characters. This can be in the table itself but ideally it would take place during the formatting/printing of particular reports. :confused:

It would also be useful to know which font(s) would offer equal sizes for each character (i.t.o. spacing) :confused:

Anyone got some ideas? Thanks :)
 
You can use the following code to insert spaces between charcters;
Code:
    Dim strOrg As String
    Dim strMan As String
    Dim i As Integer
    
    strOrg = Me.YourTextField
        
    i = 0
    
    While i <> Len(strOrg)
        i = i + 1
        strMan = strMan & Mid(strOrg, i, 1) & " "
        
    Wend
    
    Me.OutputTextField = strMan
For the secont part of the question you need to check out the Fixed-width fonts try Courier for starters.
 
Thanks JB - works like a charm - unless I encounter a blank field, when I get a Runtime error 94. I tried the If-Else-End If thing (below) but there's still something wrong with it?

Private Sub Surname_Enter()
Dim strOrg As String
Dim strMan As String
Dim i As Integer

strOrg = Me.Surname

i = 0

While i <> Len(strOrg)
If Len(strOrg) = 0 Then
strMan = vbNullString
Else
i = i + 1
strMan = strMan & Mid(strOrg, i, 1) & " "
End If
Wend

Me.Text68 = strMan
End Sub
 
Use;
Code:
Private Sub Surname_Enter()
Dim strOrg As String
Dim strMan As String
Dim i As Integer

strOrg = [URL="http://www.techonthenet.com/access/functions/advanced/nz.php"]Nz[/URL](Me.Surname, "")

i = 0

While i <> Len(strOrg)
     i = i + 1
     strMan = strMan & Mid(strOrg, i, 1) & " "
Wend

Me.Text68 = strMan
End Sub
You need to catch and deal with the Null prior to entering the For/Next loop.

Also, when you post code, use the hash (#) button at the top of the posting window to wrap your code in a code window. The code window allows you to format your text so you can inset the various steps in loops and If Then statements to make it all easier to follow
 
Thanx JB. I've got it working and I'm learning. It's great! I was wondering how all the other postings got to look so neat, box 'n all. And, I found a free font site and downloaded the proportional font I like (Railmodelfont.ttf) - I just need to figure how to add this font to Access, or perhaps Windows.
 

Users who are viewing this thread

Back
Top Bottom