Solved get only the 1st Word in Report. (1 Viewer)

JRMT

New member
Local time
Today, 12:50
Joined
Dec 3, 2020
Messages
23
Hello Sir's & Ma'ams
I need Help is there a way to get the 1st word or if i want a specific word to display in Report when i generate it?
and btw some of the words are not the same and also in the same page of the report. like for example
Car All Types - i only want Car All to Display in Report
Heavy Equipment - i only want Heavy to Display in Report
Motorcycle - i want only Motor to display in report

etc.. etc.. there are many more

i tried using this in unbound text in the Report
Code:
=left([Type],13)
but other words like Motorcycle and Heavy Equipment are not the same length as Car All Types

please help me thank you and Happy New Year!
 

June7

AWF VIP
Local time
Today, 01:50
Joined
Mar 9, 2014
Messages
5,423
And what decision logic would you expect could be programmed to accomplish this? If there is no consistency, where is the logic?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:50
Joined
Oct 29, 2018
Messages
21,357
@JRMT, if you cannot define the logic for consistently determining the first word, you could probably use a lookup table instead.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:50
Joined
May 7, 2009
Messages
19,169
pare, you copy/paste this in a new Module:
Code:
Public Function ExtractEN(ByVal strText As String) As Variant
    Dim i As Integer, l As Integer
    Dim strRet As String
    strText = strText & ""
    ExtractEN = Null
    If Len(strText) < 1 Then
        Exit Function
    End If
    l = Len(strText)
    For i = 1 To l
        If AscW(Mid$(strText, i, 1)) > 255 Then
            Exit For
        End If
        strRet = strRet & Mid$(strText, i, 1)
    Next
    strRet = Trim$(strRet)
    ExtractEN = strRet
End Function

now, to extract the English portion from your string:

=ExtractEN([type])
 

JRMT

New member
Local time
Today, 12:50
Joined
Dec 3, 2020
Messages
23
Sir Arnel Thank you so much Sir this solves my problem thank you very much!
 

Sun_Force

Active member
Local time
Today, 18:50
Joined
Aug 29, 2020
Messages
396
Sir Arnel Thank you so much Sir this solves my problem thank you very much!

Just out of curiosity. Does @arnelgp's code returns Motor when you pass Motorcycle to the function? (I believe it's one of your requirements)
I'm not in front of access to test, but following the code, I don't think it will do.
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:50
Joined
May 7, 2009
Messages
19,169
the OP has a combination of English and arabic words on the field.
the english portion is on the left side. like this one:

Car All Types مركبات (ب) السيارات بانواعها

passing this to the function, the result is all english:

Car All Types
 

Sun_Force

Active member
Local time
Today, 18:50
Joined
Aug 29, 2020
Messages
396
the OP has a combination of English and arabic words on the field.
the english portion is on the left side. like this one:
You're not only genius in Access, but also in reading OP's mind.
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:50
Joined
Sep 21, 2011
Messages
14,038
the OP has a combination of English and arabic words on the field.
the english portion is on the left side. like this one:

Car All Types مركبات (ب) السيارات بانواعها

passing this to the function, the result is all english:

Car All Types
Car All Types - i only want Car All to Display in Report
Heavy Equipment - i only want Heavy to Display in Report
Motorcycle - i want only Motor to display in report

Does not appear to be any logic behind this request? :unsure:
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:50
Joined
Oct 29, 2018
Messages
21,357
the OP has a combination of English and arabic words on the field.
the english portion is on the left side. like this one:

Car All Types مركبات (ب) السيارات بانواعها

passing this to the function, the result is all english:

Car All Types
Thanks for the explanation. Now, it makes perfect sense.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:50
Joined
May 7, 2009
Messages
19,169
Does not appear to be any logic behind this request?
i have a pm from the op but only requesting the English portion of the text.
then he refer to this thread. so my answer is the English portion and not the 1st
english word on the text.
 

Users who are viewing this thread

Top Bottom