Display multiple validation messages to the user

后端 未结 2 1268
暖寄归人
暖寄归人 2021-01-17 05:40

In MS-Access, how can I store the rows retrieved from my SELECT statement in an array, and show many rows in one messagebox:

Dim rSEL, rSUM, rDes As DAO.Reco         


        
2条回答
  •  伪装坚强ぢ
    2021-01-17 06:15

    I would not use a Message Box for this, since you could potentially have hundreds of rows, and they wouldn't all fit. Instead, I would create a custom form with a ListBox, and whenever you get the error, do the following:

    If vQnty > vSum Then
        ..AddItem("You have only (" & vSum & " ) of Item (" & vDes & " ) in the stock")
        Cancel = True
    End If
    

    If at the end of the loop, Cancel = True, display ErrorForm.

    Another thing - you may be able to create a query which does all this in one go. You need to join the three tables, and add the vQnty > vSum condition. This would be pretty neat, because you could use the query as the source of the ListBox - no code required.

提交回复
热议问题