Solved Split String (1 Viewer)

tmyers

Well-known member
Local time
Today, 02:52
Joined
Sep 8, 2020
Messages
1,090
I need a little assistance in coming up with a formula to split a string apart based on length. This is part of a module to export a recordset to an Excel file template for import into my companies system.

Code:
If IsNull("Description") then
    'do nothing'
Else
    If Len("Description") > 60 then
        'split string'
    End if
End if

My field has a cap of 60 characters, so if the threshold is reached, I need to split the string into a second row but I obviously don't want to cut words in half, so I need to back track to the first space or " " and split the string there. I am very bad when it comes to using string functions (len, left, right, etc) as I dont have much experience with them.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:52
Joined
Oct 29, 2018
Messages
21,473
Check out this other thread.
 

tmyers

Well-known member
Local time
Today, 02:52
Joined
Sep 8, 2020
Messages
1,090
That looks like it will have the answer for this thanks!
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:52
Joined
Sep 21, 2011
Messages
14,299
I am very bad when it comes to using string functions (len, left, right, etc) as I dont have much experience with them.
Well they do say practice makes perfect? :)
 

tmyers

Well-known member
Local time
Today, 02:52
Joined
Sep 8, 2020
Messages
1,090
Well they do say practice makes perfect? :)
Indeed it does!
The main problem I was grappling with was not cutting words into pieces but am reading that thread now. I like the module JDraw shared. The one I currently use to deal with strings that are too long doesnt care about cutting words apart as that is just how it is done in the system I am importing into for this field.
Code:
    If Len(rs("CatalogNo")) > 60 Then
        vCatalog = Left(rs("CatalogNo"), 60)
        vDesc = Mid(rs("CatalogNo"), 61)
    End If
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:52
Joined
Sep 21, 2011
Messages
14,299
Well you could always just concatenate them back together again for display, and no one would any the wiser?
 

Users who are viewing this thread

Top Bottom