A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

limitations/specifications for the Format Function



 
 
Thread Tools Display Modes
  #1  
Old February 8th, 2006, 07:27 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default limitations/specifications for the Format Function

I am trying to use the format function to right-pad strings.

For instance, i have a string x that must have a length of 365 characters
(to match a custom data type). After a user enters a value for x (which may
not be 365 characters), i have to convert it to a string with a length of 365.

Here is an example:
dim t as string, sNew as string, s as string
's is obtained from a text box -
s="SELECT GPDate, GPTitle, GPCo FROM tblGPType Where GPType = 4 And GPCo =
Question('CoGrp') ORDER BY GPActDate DESC;"

t="!" & string(365,"@") 'creates a format template

sNew = format(s,t)

I expect sNew to be the same as s padded to the right with spaces to a
length of 365. However, what is returned is
"T GPDate, GPTitle, GPCo FROM tblGPType Where GPType = 4 And GPCo =
Question('CoGrp') ORDER BY GPActDate DESC; ........"

It has a length of 365, but several of the initial characters from the s
have been truncated.

I can't find any documentation that would explain this behaviour, but it
sure is giving me a headache.

Any one have an idea as to what is going on?

thanks

--
dchman
  #2  
Old February 8th, 2006, 07:56 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default limitations/specifications for the Format Function

You don't need the format function here. all you need is:
sNew = s & Space(365 - Len(s))

"dchman" wrote:

I am trying to use the format function to right-pad strings.

For instance, i have a string x that must have a length of 365 characters
(to match a custom data type). After a user enters a value for x (which may
not be 365 characters), i have to convert it to a string with a length of 365.

Here is an example:
dim t as string, sNew as string, s as string
's is obtained from a text box -
s="SELECT GPDate, GPTitle, GPCo FROM tblGPType Where GPType = 4 And GPCo =
Question('CoGrp') ORDER BY GPActDate DESC;"

t="!" & string(365,"@") 'creates a format template

sNew = format(s,t)

I expect sNew to be the same as s padded to the right with spaces to a
length of 365. However, what is returned is
"T GPDate, GPTitle, GPCo FROM tblGPType Where GPType = 4 And GPCo =
Question('CoGrp') ORDER BY GPActDate DESC; ........"

It has a length of 365, but several of the initial characters from the s
have been truncated.

I can't find any documentation that would explain this behaviour, but it
sure is giving me a headache.

Any one have an idea as to what is going on?

thanks

--
dchman

  #3  
Old February 8th, 2006, 08:04 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default limitations/specifications for the Format Function

thanks, i forgot about the space function - i can stop banging my head
against the wall now (luckily the cube walls are padded)
--
dchman


"Klatuu" wrote:

You don't need the format function here. all you need is:
sNew = s & Space(365 - Len(s))

"dchman" wrote:

I am trying to use the format function to right-pad strings.

For instance, i have a string x that must have a length of 365 characters
(to match a custom data type). After a user enters a value for x (which may
not be 365 characters), i have to convert it to a string with a length of 365.

Here is an example:
dim t as string, sNew as string, s as string
's is obtained from a text box -
s="SELECT GPDate, GPTitle, GPCo FROM tblGPType Where GPType = 4 And GPCo =
Question('CoGrp') ORDER BY GPActDate DESC;"

t="!" & string(365,"@") 'creates a format template

sNew = format(s,t)

I expect sNew to be the same as s padded to the right with spaces to a
length of 365. However, what is returned is
"T GPDate, GPTitle, GPCo FROM tblGPType Where GPType = 4 And GPCo =
Question('CoGrp') ORDER BY GPActDate DESC; ........"

It has a length of 365, but several of the initial characters from the s
have been truncated.

I can't find any documentation that would explain this behaviour, but it
sure is giving me a headache.

Any one have an idea as to what is going on?

thanks

--
dchman

  #4  
Old February 8th, 2006, 08:10 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default limitations/specifications for the Format Function

I wondered what that banging noise was on my cube wall. It was interfering
with my nap.

"dchman" wrote:

thanks, i forgot about the space function - i can stop banging my head
against the wall now (luckily the cube walls are padded)
--
dchman


"Klatuu" wrote:

You don't need the format function here. all you need is:
sNew = s & Space(365 - Len(s))

"dchman" wrote:

I am trying to use the format function to right-pad strings.

For instance, i have a string x that must have a length of 365 characters
(to match a custom data type). After a user enters a value for x (which may
not be 365 characters), i have to convert it to a string with a length of 365.

Here is an example:
dim t as string, sNew as string, s as string
's is obtained from a text box -
s="SELECT GPDate, GPTitle, GPCo FROM tblGPType Where GPType = 4 And GPCo =
Question('CoGrp') ORDER BY GPActDate DESC;"

t="!" & string(365,"@") 'creates a format template

sNew = format(s,t)

I expect sNew to be the same as s padded to the right with spaces to a
length of 365. However, what is returned is
"T GPDate, GPTitle, GPCo FROM tblGPType Where GPType = 4 And GPCo =
Question('CoGrp') ORDER BY GPActDate DESC; ........"

It has a length of 365, but several of the initial characters from the s
have been truncated.

I can't find any documentation that would explain this behaviour, but it
sure is giving me a headache.

Any one have an idea as to what is going on?

thanks

--
dchman

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
determine if Excel is open geebee General Discussion 11 January 20th, 2006 09:25 PM
Format function not working in queries? lwert Running & Setting Up Queries 1 October 12th, 2005 05:48 AM
Function for reading cell format msbaby Worksheet Functions 2 October 6th, 2004 01:55 PM
email format Lloyd General Discussion 1 June 16th, 2004 03:42 AM
Return a format by VBA function Titoun Worksheet Functions 1 January 7th, 2004 07:15 PM


All times are GMT +1. The time now is 04:12 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.