• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 142
  • Last Modified:

Easy Peasy String question(that I have forgotten)

Hi, have a field in a table which is 50 characters long and another which is 10 chars long.  How would I put this into a string of 60 chars long beginning with the 50 and adding the 10 onto it without it taking out the blank chars in the 50 which are not used?  for example..

"David Cassidy & Co                                0000001234"

But I get..

"David Cassidy & Co0000001234"


Thanks, Derek.
0
Delboy
Asked:
Delboy
1 Solution
 
trkcorpCommented:
Try like:
result = mid$(!Co_Name, 1,50) & !Co_Number
0
 
trkcorpCommented:
If that doesn't work then perhaps the data is truncated so pad it:
result = mid$(!Co_Name & Space(49), 1,50) & !Co_Number
0
 
PaulHewsCommented:
= Left$(rs("Field50") & space(50), 50) & rs("Field10")
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
DelboyAuthor Commented:
Second one did the job..  many thanks
0
 
JohnMcCannCommented:
In order to do this accuratly you need to declare to strings of fixed length cast your db fields into the fixed length strings and then concaternate the two strings.  Something like this

Private Sub Form_Load()
Dim str1 As String * 50
Dim str2 As String * 10

   str1 = "David Cassidy & Co"
   str2 = "0000001234"
   MsgBox str1 & str2
End Sub

0
 
trkcorpCommented:
Thanks for the points, I like paul's answer & john's would work as well...
0
 
PaulHewsCommented:
:) You beat me to it.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now