简体   繁体   中英

Ms access VBA select case

My code is running on different tables, so each table has different number of rows.

I would like to have SELECT CASE nLine so I can group them to 5 rows.

Where each group while have different code according to row.

row = 1 will have code 1.

row 2 - 4 will have code 2.

row = 5 will have code 5.

Select Case nLine
    Case 1
       Code 1
    Case 2 - 4
       Code 2
    Case 5
       Code 3
End Select
Loop <===Start again from above SELECT CASE

So, I need a code to group my rows to 5rows per group. And on each Group, to run this code.

What's the purpose of this grouping? If it's for display purposes create a calculated field in a query and use that.

GroupNo: IIf([nLine] = 1,1,IIf([nLine] = 5,3, 2))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM