Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTS ActiveX VBScript problem 1

Status
Not open for further replies.

panini

MIS
Jun 1, 2001
136
GB
Hi there,

I had some really great help a while back for a script problem i had, but it's giving me some weird results... this is the original question..

"I've got an activex script that emails orders out to suppliers. They need to receive the data in a particular format - and need some field lengths to be a particular size... the problem i'm having is if i use this code....

elseif x.name = "title" then
strLine= strLine & chr(34) & left(x.value,4) & chr(34) & chr(44)

and the title field is nchar then i get a field entry of "MR ", (which is right) but if the title field is varchar i get "MR", (which is wrong)

Does anyone know how why this happens or if I can get around it without changing all my database fields?"

and answer...

"Varchar means the field content is just as long as the data you enter. In any event you can change your script to fix it:

strLine= strLine & chr(34) & left(x.value & " ",4) & chr(34) & chr(44)"

Now what is happening occasionally is if a field has very little data in it - say a 2 digit personalised car number plate 'W1' - rather than the expected say 8 characters, and my code wants to pull out a constant 10 digits and says

strLine= strLine & chr(34) & left(x.value & " ",10) & chr(34) & chr(44)"

then i'm getting say only 7 or 8 digits coming through so "W1 " for example instead of "W1 "

Its working fine apart from those times when the data is much smaller than the field would normally have.

Any thoughts or ideas gratefully accepted
 
I didn't get it, why would you start changing databas fields..

DIfferent lenght for nchar and varchar, because nchar and char datatype's will always fillup to the lenght they are definied, so char(3) will always have 3 characters even if you try value="A", it will be "A ". Varchar is as long or short as you fill it, of course up to the maximum.

That
left(x.value & " ",4) idea is ok, it's just if you increase the number, you have to lengthen the string of spaces, good advice is to have as many spaces as the number, so try this and it works:
left(x.value & " ",10)
or even better
left(x.value & String(10, " "),10)
just have the numbers same

There are other alternatives too.

Cheers
 
many thanks yksvaan - that was a real help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top