从多个表获取最大数字?

发布于 2025-02-13 17:54:16 字数 302 浏览 0 评论 0原文

我在一个名为PrivateCustomerInfo,BusinessCustomerInfo和NHCustomerInfo的访问项目中有多个表格,每个表都有一个名为“ CustomerId”的列,并且我有一个单独的表单,用于使用增量客户ID添加新客户。为此,我使用了nz(dmax(“ [customerid iD]”,“ privateCustomerInfo),每个表基本上从所有3个表中获取了最大的客户ID。但是,我不确定如何确定如何将这三个数字一起查找最大的数字,然后通过一个新的添加来进行一个,我可以在线阅读。是否有任何建议,对访问VBA不起作用吗?

I have multiple tables in an access project named PrivateCustomerInfo, BusinessCustomerInfo and NHCustomerInfo, each table has a column named "customerid" and I have a separate form that is used to add new customers into the designated table with a incremental customer ID. To do this I used Nz(DMax("[customerid]","PrivateCustomerInfo and so on for each table to basically get the largest customer ID from all the 3 tables. However, I am unsure how to compare these 3 numbers together to find the largest one and then increment by one for the new addition. I read online that you could do Max(value1, value2, value3...) but this doesnt work on Access VBA, any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

〆凄凉。 2025-02-20 17:54:16

我已经写了自己的功能,可以用不同数量的参数来调用,哪些可以返回其中最大的参数

Public Function MaxVal(x As Variant, ParamArray y() As Variant) As Variant
    Dim max As Variant, i As Long
    
    max = x
    For i = LBound(y) To UBound(y)
        If IsNull(max) Then
            max = y(i)
        ElseIf y(i) > max Then
            max = y(i)
        End If
    Next i
    MaxVal = max
End Function

I have have written my own function that can be called with a varying number of arguments and which returns the greatest of them

Public Function MaxVal(x As Variant, ParamArray y() As Variant) As Variant
    Dim max As Variant, i As Long
    
    max = x
    For i = LBound(y) To UBound(y)
        If IsNull(max) Then
            max = y(i)
        ElseIf y(i) > max Then
            max = y(i)
        End If
    Next i
    MaxVal = max
End Function
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文