Query Select first digits

Joanna_gr

Board Regular
Joined
Feb 16, 2002
Messages
149
Hi again. Can you please help me on this? I'm trying to create a query from a list of data that some of them begins with 3digits like "283 - name" and some other with 4 digits like "2222 - name". Can you tell me how to select all records that start with 4digts? Like LEFT in excel.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Well you can use Left in Access just as you do in Excel.

Does the - always seperate the number and name?
 
Upvote 0
I tried to use LEFT but it didn't work. :( how can I use it in a query? Yes the - always seperates numbers from text.
 
Upvote 0
How are you trying to use it?

You could try something like this.

Expr1: Left([Field1],InStr([Field1],"-")-2)
 
Upvote 0
Well, i'm afraid I did not make myself clear enough. This solution seperates numbers from text. This is not what I want. In fact I need to have all records that start with 4 digits and exclude records that start with a 3digit num. etc
3333 - name1
3434 - name2
3432 - name3
something like filtering the column and keep only records with 4dgt and hide all other. (In my list I also have records starting with 2 num. "22 - name1".
 
Upvote 0
Well you could use this expression.

Expr1: Len(Left([Field1],InStr([Field1],"-")-2))

And set the criteria to 4.
 
Upvote 0

Forum statistics

Threads
1,221,905
Messages
6,162,770
Members
451,786
Latest member
CALEB23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top