Need to Query last 6 digits of field

kmclane

New Member
Joined
Apr 1, 2004
Messages
42
I have a field with a 16 digit number in it. The first 10 are all the same. I am trying to set up a query that will allow users to input the last 6 and get a match. I'm not sure how to do this. I thought I could do it in the criteria field, but I don't know exactly how to start? :oops:
Any suggestions would be appreciated. Ken
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
You want to use a custom query field.

Field Name in Query
Test: right([Field Name],6)

[Field Name]=Your Field Name

Criteria
[Last 6 digits]

This should cause the query to prompt you with an input box for the 6 digit number.(You won't be able to set any validation, so the user could input a 12 digit number, if you want validation, I would suggest setting up a form to pass the parameter)

Hope this helps.
 
Upvote 0
Here is the code, I have tried to change it in the way you suggested, but I keep getting errors, so I must be doing it wrong.

SELECT CurrentARUMonth.TerminalNumber, CurrentARUMonth.Date, CurrentARUMonth.Time, CurrentARUMonth.CardNumber, CurrentARUMonth.ExpirationDate, CurrentARUMonth.PurchaseAmount, CurrentARUMonth.AuthCode
FROM CurrentARUMonth
WHERE (((CurrentARUMonth.TerminalNumber)=[Enter Last Six of MID]));

Can you tell me where it goes? I tried incorporating it into my WHERE, but it didn't work.

Thanks, Ken
 
Upvote 0

Forum statistics

Threads
1,221,675
Messages
6,161,216
Members
451,691
Latest member
fjaimes042510

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