简体   繁体   English

MS Access VBA选择案例

[英]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. 我想要SELECT CASE nLine所以我可以将它们分组为5行。

Where each group while have different code according to row. 其中每个组同时根据行有不同的代码。

row = 1 will have code 1. 行= 1将具有代码1。

row 2 - 4 will have code 2. 第2-4行的代码为2。

row = 5 will have code 5. row = 5将具有代码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. 因此,我需要一个代码来将行分组为每组5行。 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))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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