Create string using function in calculated field

Kronix

Registered User.
Local time
Tomorrow, 00:04
Joined
Nov 2, 2017
Messages
102
I want to create a calculated field that takes two other integer fields in the table, RBeginn and RLength, and creates a string containing a sequence of numbers.

For example, if RBeginn is -2, and RLength is 6, the string should contain "-2,-1,0,1,2,3".

I've already created a function in a module as follows

Code:
Public Function seqReturn(RBeg As Integer, RLen As Integer) As String
    Dim counter As Integer
    Dim RSeq As String

    RSeq = RBeg

    For counter = RSeq + 1 To RSeq + Nz(RLen, 2) - 1
        RSeq = RSeq & ", " & counter
    Next counter

    seqReturn = RSeq
End Function

But when I enter this into the calculated field as seqReturn(RBeginn, RLength) it tells me the function cannot be used in the calculated field.
 
A calculated field can only contain "values from fields in the same table as well as built-in Access functions". You'd have to manage it manually.
 
just use your function in a query
 

Users who are viewing this thread

Back
Top Bottom