By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,481 Members | 1,211 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,481 IT Pros & Developers. It's quick & easy.

Character that displays as a blank

P: 675
Access 2003 strips trailing blanks from text in tables. It also strips trailing blanks for control properties on forms.
I have a tab control where I want to pad shorter captions with blanks so all tabs are equal width. I want to center these captions, so I need to include trailing blanks that are not stripped by Access.
What character (hex value) will show on forms as a blank, not a null, but will not be removed by Access?
Jun 28 '10 #1
Share this Question
Share on Google+
8 Replies

Expert 5K+
P: 8,701
Now sure if this will work, but try using the Space() Function. The following code will pad any String will Spaces on the Back End to a Constant Length of 32:
Expand|Select|Wrap|Line Numbers
  1. Const conWIDTH As Byte = 32
  2. Dim strCaption As String
  4. strCaption = "Caption 1"
  6. strCaption = strCaption & Space(32 - Len(strCaption))
P.S. - Chr$(32) or &H20 will also generate a Space Character
Jun 28 '10 #2

Expert 100+
P: 1,240
I think you have stated the problem wrong. If you are centering the captions, then adding blanks to the end will only take the caption off of center alignment and it will tilt to the left.

The problem is to set the .width property of the tabs. You can do that programmatically or with the GUI at design time. There is a property on the tab control called TabFixedWidth. It is normally zero, which lets the tabs vary in width to fit the provided text. Change that setting to be long enough for your widest tab label.


Jun 28 '10 #3

Expert 100+
P: 1,240
Another helpful thing to remember is that you can specify fixed length strings.
dim A as string * 20 makes a fixed 20 character string. You could also try using that to your advantage here, something like this
Expand|Select|Wrap|Line Numbers
  1. dim strA10 as string * 10
  2. strA10 = tab1.caption
  3. tab1.caption = strA10
  4. strA10 = tab2.caption
  5. tab2.caption= strA10
  6. strA10 = tab3.caption
  7. tab3.caption= strA10
Jun 28 '10 #4

P: 675
Space() is a variation of String(). Neither works for this. Whether I enter "XXX ", "XXX" & Space(5), "XXX" & String(5, 32), or "XXX" & " ", the results are the same, when entered into a table.
For assigning to .Caption in design view of a form, the text becomes literal, and my tab contains "XXX & Space(5)"
Assigning into .Caption at runtime doesn't work either. Access strips the trailing blanks.

I'm tracking use of a building, 4 floors, 6 rooms/floor.
I wanted the tab control to be:
Expand|Select|Wrap|Line Numbers
  1.    1      2      3      4      5      6
  2.   101    102    103    104    105    106
  3.   201    202    203    204    205    206
  4.   301    302    303    304    305    306
  5.      Office           Storage Room
I thought if I could enter " 2 " for room #2, I could make the tabs show as a matrix, and fill the row space. But " 2 " becomes " 2" for all these suggestions.

I can live with Fixed Width Tabs. I was just hoping for either fixed widths per each tab, or using blanks to force the width to larger than Access default.

Note: This site strips blanks, so my example for room #2 with 3 leading and 3 trailing blanks is stripped to one each.
Jun 28 '10 #5

Expert Mod 15k+
P: 31,768
I expect it depends on your CodePage OB, but with some preliminary tests I found 95 (8F) & 160 (A0) at least showed no character. I haven't got a tab control to test it on, but they may be worth checking. Otherwise Jim's suggestion seems as if it may take you where you want to go I would think. Good luck anyway.

PS. I managed a test on a label category. 95 was no good, but 160 seemed to work. Be advised though, I doubt it's very portable/reliable.
Jul 5 '10 #6

P: 675
Thank you for the replies.
On my machines, the character 95 (8F) is an 'a' with an accent over it, an extended alphabet character. It shows on a tab as this character, not as a blank.

The character 160 (A0) is the underscore. It also shows in both tab controls and label controls.

I have 2 solutions to my initial question:
1) Start and end each tab caption with a period(.). With a bold font, this gives the control a riveted, or hi-tech appearance.
2) Use Jim's suggestion as follows:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Dim i As Integer
  3. ...
  4.     'Initialize tab captions - Cannot be done at design time: Access strips trailing blanks
  5.     For i = 0 To 23
  6.         If i < 6 Then
  7.             tabUnits.Pages(i).Caption = Space(7) & Int(i / 6) * 100 + 1 + i Mod 6 & Space(7)
  8.         Else
  9.             tabUnits.Pages(i).Caption = Space(5) & Int(i / 6) * 100 + 1 + i Mod 6 & Space(5)
  10.         End If
  11.     Next i
  12.     tabUnits.Pages(24).Caption = "                 Office                "
  13.     tabUnits.Pages(25).Caption = "               Storage Room                 "
  14. ...
  15. End Sub
Note: All lengths and number of spaces are determined by 'trial-and-error'. The width of the tab control, the font size, the font weight, and the font name all determine how much space the actual characters use.
In my example, I cannot use 'Tab Fixed Width' because of the 2 un-numbered rooms. Proportional spacing with FontName=Tahoma makes the 2 different space() lengths necessary for room numbers less than 100.
Jul 6 '10 #7

Expert 100+
P: 1,240
Steven Lebans created a sample mdb to automatically resize a textbox (or other control) to fit the text that needed to be in it. The exact description from within the routine reads:
"Returns Control Width & Height needed to display the contents of the Control passed to this function."

Maybe that has the key to your solution. It uses a lot of API calls and takes the control's font property into consideration when making the calculation. You can find it at

You could come up with something using that at runtime to calculate the needed size after all captions are known, and then automatically set the tab width property.

I hope this helps.

Jul 6 '10 #8

P: 675
Thanks Jim.
This is a form design problem. I wanted tabs that were larger than Access created by default. I also wanted the tabs to form a logical matrix, room 203 in the same column as 103 & 303.
My original post shows what I want. I changed the font size to increase the individual tab's width, but beyond FontSize=14, the text was overpowering.
I tried fixed-width tabs, but the 2 non-numbered rooms defeated that approach.
I padded the numbers with leading blanks, which works well, but the numbers are not centered on the tabs. So I tried to pad to the right, but Access strips the trailing blanks in Design View.
Solution is to assign the tab captions at run-time. Works quite well, thank you. It just takes trial-and-error to balance the number of leading/trailing blanks, the font size, the tab width, and the tabcontrol width.
I'm happy with this.
Jul 6 '10 #9

Post your reply

Sign in to post your reply or Sign up for a free account.