VBA Access - Returning some kind of blank / null for a function declared as long

Question: I want to use the VBA function in Access declared as a type of Long. I want to return an integer from 0 to 35 for a while, but I also want to be able to return empty or null or something like that most of the time. Is there any way to do this? What I tried (variable = "" or Set variable = Nothing) just causes an error. This will be used in the query and will give a value for one column. I want this column to be a Long type. If such a thing is not possible, I think that’s all I need to know, since I already have a different but less desirable solution. Thanks for any help.

Update: Of course, right after the question, I realized that this is a good solution. If I just do Range ("independently"). Value = Range ("whatever"). A value in Excel, then it changes left justification 20 to right justification 20 when it is recognized by the pivot table as a number (although when I simply convert the cell type to a number in Excel, it is not recognized as a number in the pivot table). So, I delete the background because it is optional. I'm still curious to know if you can return some kind of space or null for the declared function. Thanks

+4
source share
2 answers

Null can only be returned using the Variant function.
Nothing can only be returned from the Object function.

All the rest, you are limited to returning a variable of the type defined as the return value of your function.
If you do not set a value, it returns the default value.
A numeric variable is initialized to zero
A variable-length string is initialized to a null string ("")
A fixed-length string is populated with ASCII code 0.
Date / Time parameter initialized to zero

+7
source

Since the unified long is 0, the answer is no. A function declared as long cannot return null or empty. If zero is not a valid return value for your function, you can use it as the "null" equivalent, but you already knew that :)

+2
source

All Articles