Sequence Numbers in Access Query

Moxioron

Active Member
Joined
Mar 17, 2008
Messages
436
Office Version
  1. 2019
Hello.

Please see my SQL below. Everything is working fine, except I have to account for duplicates.

What I want to do: If there are duplicate Member Number fields, then sequentially use L25 for the first one, L26 for the second, so on and so forth.

Any ideas? Thanks.


SELECT [tbl_Credit Card Detail for Card Conversion_Updated].[Card Number], [tbl_Credit Card Detail for Card Conversion_Updated].[Member Number], [Member Number] & "C" & [Card Number] AS Expr1, [Member Number] & "L125" AS Expr2, IIf([External Status Code] In ("Z","B","E","A","L","U","I") And [Account Balance Total Amount]>0,"X",IIf([External Status Code] Is Null,"X","")) AS Expr3, [tbl_Credit Card Detail for Card Conversion_Updated].[External Status Code], [tbl_Credit Card Detail for Card Conversion_Updated].[Account Balance Total Amount], [tbl_Credit Card Detail for Card Conversion_Updated].ID
FROM [tbl_Credit Card Detail for Card Conversion_Updated]
WHERE ((([tbl_Credit Card Detail for Card Conversion_Updated].[Member Number]) Is Not Null And ([tbl_Credit Card Detail for Card Conversion_Updated].[Member Number])<>"0000000" And ([tbl_Credit Card Detail for Card Conversion_Updated].[Member Number])<>"1" And ([tbl_Credit Card Detail for Card Conversion_Updated].[Member Number])<>"000000" And ([tbl_Credit Card Detail for Card Conversion_Updated].[Member Number])<>"0000001") AND ((IIf([External Status Code] In ("Z","B","E","A","L","U","I") And [Account Balance Total Amount]>0,"X",IIf([External Status Code] Is Null,"X","")))="X"));
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Since L125 is hardcoded into your SQL -- assuming you mean L125 and not L25 -- , this is not possible. In general, with Access SQL its not something you can do even with ordinary sequential numbers (1,2,3...). First question is why do you have duplicates that you want to treat as not being duplicates - perhaps you can avoid this at an early stage with better data (for instance, by getting the PRIMARY KEYS along with the rest of the data).
 
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,985
Members
452,540
Latest member
haasro02

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