Access VBA, delete some characters inside a String

AccOUCH

Registered User.
Local time
Today, 08:40
Joined
Sep 27, 2018
Messages
25
I have several records that include some text between square brackets -->

Code:
aaaaaa[aaaaa].
I need to erase that extra content, square brackets included. The String in the example would turn out to be:

Code:
aaaaaa
I'm trying this code:

Code:
Dim sqr as Integer
Dim origin as String
Dim result as String

InStr(origin,[)
So I can find the first square bracket, but I does not do the job.

Any idea?
 
Last edited:
The arguments of InStr are strings (https://www.techonthenet.com/oracle/functions/instr.php). You have declared the variable origin as a string--however nothing is inside it. origin is null and thus nothing will ever be found inside of it to match. Next you have used the symbol [, which Access has no clue about. Its not a variable and you haven't surrounded it by quotes (which is how you make strings), so it has no idea what you meant to do with it.
 
If you simply want to discard the entire string to the right of the first [ character you are on the correct path.

Origin = "Your test[String]"

Msgbox Left([Origin], InStr([Origin], " [") - 1)
 
Thanks! It has been a pair of good solutions!
 

Users who are viewing this thread

Back
Top Bottom