MS Access 调用函数

MS Access calling a function

我正在为 Access 中的俱乐部会员编写程序。单元格 1 将包含一个数字,单元格 2 将包含单元格 1 的罗马数字数字。

我有一个可以转换数字的函数,但我无法将单元格 1 的值输入函数,将答案输入单元格 2。函数的开头是

Public Function RomanNumeral(ByVal aValue As Long) As String

并以

结尾
RomanNumeral = strResult 

如果有人能提供帮助,我将非常高兴

好的,这将是一个计算字段。为此,您将 =myFunction() 用作 ControlSource

在您的情况下,如果数字字段的名称为 myNumber,请将其用于罗马数字字段:

=RomanNumeral([myNumber])

编辑

如果您不需要计算字段,而是 table 中的字段,请为数字字段创建一个 AfterUpdate 事件过程,您可以在其中设置第二个字段:

Private Sub myNumber_AfterUpdate()
    ' Use Nz to avoid runtime error when myNumber is NULL
    Me!RomanNumber = RomanNumeral(Nz(Me!myNumber, 0))
End Sub