bd528
bd528

Reputation: 886

Finding highest value in field where first 2 numbers match

In Access 2016 VBA, I have a field that holds 8 digit numbers.

I need to find the highest numbers where the first 2 digits match. Some sample data :-

Dim tempsalesref As Double

tempsalesref = 34

34000001
34000002
34000003

So in this case my query would be based on 34, and the value to be returned, as it's the highest, would be 34000003.

Is it possible to do this?

Upvotes: 0

Views: 51

Answers (1)

Mike Makarov
Mike Makarov

Reputation: 1356

As discussed in comments, the approach may be changed to simplify the task. Just use the sql query, a prototype with x and y being the key numbers: select Max(your_column ) from your_table where your_column >= xy000000 and your_column <= xy999999

Upvotes: 2

Related Questions