Solved Drop Everything after a Certain Character

safril

New member
Local time
Tomorrow, 04:16
Joined
Aug 7, 2021
Messages
14
Hi, now I'm working with Access table and I have a table called "Field01" that contain something like:
Code:
12-K/PM.III-12/AD/VII/2021
I need to drop or trim all of the characters after the first "/" so it will be like:
Code:
12-K
Anyone can help? Thanks in advance ;)
 
Try this
Code:
Sub aug7()

Dim str As String: str = "12 - k / PM.iii - 12 / AD / VII / 2021"
Debug.Print IIf(str Like "*/*", Left(str, InStr(str, "/") - 1), "no slash found")
End Sub

Result:

12 - k
 
Use Instr() and Left() functions
 
SQL:
LEFT([Field01],InStr([Field01],"/")-1)
 
if you are using Query use :

Left$([FieldName], Instr(1, [FieldName], "/")-1)

otherwise you can use Split():

Split([FieldName], "/")(0)
 
Try this
Code:
Sub aug7()

Dim str As String: str = "12 - k / PM.iii - 12 / AD / VII / 2021"
Debug.Print IIf(str Like "*/*", Left(str, InStr(str, "/") - 1), "no slash found")
End Sub

Result:

12 - k
Sorry, my fault. I'll using the syntax in Expression Builder 🙏
SQL:
LEFT([Field01],InStr([Field01],"/")-1)
I've got "Syntax error in expression."
if you are using Query use :

Left$([FieldName], Instr(1, [FieldName], "/")-1)

otherwise you can use Split():

Split([FieldName], "/")(0)
Thank you very much! It's work perfectly in Expression Builder :D(y)
 

Users who are viewing this thread

Back
Top Bottom