Share via

Truncate text string

Anonymous
2011-09-07T19:47:37+00:00

I have a field (InvoiceGL) that contains text strings that are our account codes. Many of them are like the following: 123.000.345.1234.1AB

What I want to do in my query is remove the "1AB" listed at the end. It's not always three characters, so I want to find the last reference to "." and return whatever is to the left of it. I've played with inStr but can't seem to get the correct syntax down. Right now I'm using:

TrimCode: Left([InvoiceGL],Right([InvoiceGL],InStr([InvoiceGL],".")-1))

But this is giving me a #Error message when I run the query. Your help is greatly appreciated!

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-09-07T19:53:31+00:00

Try something more like:

TrimCode: Mid([InvoiceGL],1,instrrev([InvoiceGL],".")-1)

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2011-09-07T20:04:43+00:00

    Perfect. Thanks!

    Was this answer helpful?

    0 comments No comments