how to insert a tab into a query expression (1 Viewer)

evillarrealca

New member
Local time
Yesterday, 18:21
Joined
Mar 23, 2020
Messages
15
Hi all,

I'm trying to insert a Tab into a query expression but chr(9) and vbTab doesn't work, does anybody knows what is that need to be used?
 

vba_php

Forum Troll
Local time
Yesterday, 18:21
Joined
Oct 6, 2019
Messages
2,880
i would say the question would NOT be why you're looking for answer to this, but why you are needing it anyway, especially in a query field. what for? for spatial data? if so, that would make no sense, and it would be better for you to "tab" out your data by putting it in different fields. I believe the following DOES work in code:
Code:
Chr(9)

vbtab
 

strive4peace

AWF VIP
Local time
Yesterday, 18:21
Joined
Apr 3, 2020
Messages
1,006
hi evillarrealca,

actually, that WILL insert a TAB character in a query ... just that Tabs aren't defined so you can't see the space. If you paste the results into Excel, they will separate into different columns at the Tab character(s)

What are you trying to do?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:21
Joined
May 7, 2009
Messages
19,245
you just can't. but...
you can use chr(32), space character.
the right part after the "tab" might not align correctly.
so, you need to use Monospace Fonts (ei, Courier New, etc. or google it)
to display your query.
you also need to calculate how many space to concatenate
on a variable length string (on the Left).
below is a sample using id (long), concat to another (text) field:

Expr1: [ID] & Space(12-Len(Trim([ID] & ""))) & [orderdate]

run and change the the Font to Courier New.
 

evillarrealca

New member
Local time
Yesterday, 18:21
Joined
Mar 23, 2020
Messages
15
hi evillarrealca,

actually, that WILL insert a TAB character in a query ... just that Tabs aren't defined so you can't see the space. If you paste the results into Excel, they will separate into different columns at the Tab character(s)

What are you trying to do?
I'm trying to differentiate accounts from sub-accounts by a tab indent.
TI want it to look like this:

Sales
Uniforms Sub-account of Sales
Inscription Sub-account of Sales

Sales and Uniforms are the account name but Uniforms is related to Sales. In the Query I have a column by the name of the account but when display it I want it to indent the sub-account .
If I add space between the account and the sub-account text and take into consideration the length of the account name, as you may know, the space is regular. The problem raises with the list of accounts so the sub-account are not aligned.

They look like this:

Sales
Uniforms Sub-account of Sales
Inscription Sub-account of Sales
 

evillarrealca

New member
Local time
Yesterday, 18:21
Joined
Mar 23, 2020
Messages
15
you just can't. but...
you can use chr(32), space character.
the right part after the "tab" might not align correctly.
so, you need to use Monospace Fonts (ei, Courier New, etc. or google it)
to display your query.
you also need to calculate how many space to concatenate
on a variable length string (on the Left).
below is a sample using id (long), concat to another (text) field:

Expr1: [ID] & Space(12-Len(Trim([ID] & ""))) & [orderdate]

run and change the the Font to Courier New.
I'll give it a try with the change of font. Because I already try the Space (12-len(Trim([fieldname] & ""))) and did not work.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 18:21
Joined
Feb 28, 2001
Messages
27,193
The problem here is that depending on your preferred method of display, you might not get the alignment you want anyway. Proportional fonts, particularly ones that do kerning, would make position problematical.

However, IF you were trying to build a string that will be sent to a ASCII text file, you could use the SPACE$ function to generate n spaces in that function's position. Note that this is NOT something you would EVER want to store in the DB itself because it would interfere with identifying the stored field later. You would store the indentation level as a separate string, perhaps.
 
Last edited:

strive4peace

AWF VIP
Local time
Yesterday, 18:21
Joined
Apr 3, 2020
Messages
1,006
hi evillarrealca,

why don't you make a Grouped Report instead?
  1. click on the Create ribbon.
  2. Choose Report Wizard
  3. When the dialog box pops up, choose the table (or query) you want and then select the fields (double-click a field to move it from the left-hand list to the Selected Fields list on the right, or select a field and click the ">" button. Use the ">>" button if you want to select all the fields -- but better to pick them in the order you want them to appear.
  4. click Next
  5. For Add Grouping levels, choose the manager
  6. click Next
  7. and follow the rest of the steps
 

evillarrealca

New member
Local time
Yesterday, 18:21
Joined
Mar 23, 2020
Messages
15
hi evillarrealca,

why don't you make a Grouped Report instead?
  1. click on the Create ribbon.
  2. Choose Report Wizard
  3. When the dialog box pops up, choose the table (or query) you want and then select the fields (double-click a field to move it from the left-hand list to the Selected Fields list on the right, or select a field and click the ">" button. Use the ">>" button if you want to select all the fields -- but better to pick them in the order you want them to appear.
  4. click Next
  5. For Add Grouping levels, choose the manager
  6. click Next
  7. and follow the rest of the steps
thanks. I'll use this with the report. I was trying to use it in a Form but from the link of Galaxiom I guess it is still a problem.
 

Users who are viewing this thread

Top Bottom