1
Function CC1(BP As short, CC As short) As String
    If BP = 1 Then
    cc = "B*"
      Else
    cc = "C*"
   End If
End Function

I tried to call the above function in access query, but if says compile error

Access query has this function in below format

n: CC1([BP],[CC])
1
  • Declare as Long. Commented Aug 1, 2018 at 5:45

3 Answers 3

2

VBA doesn't have a data type short.

https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/data-type-summary

Sign up to request clarification or add additional context in comments.

Comments

1

As mentioned Short doesn't exist.

Declare as Long which can easily cater for signed 16-bit (2-byte) integers that range in value from -32,768 through 32,767.

Why Long? See the lengthy discussion here: Why Use Integer Instead of Long?

3 Comments

thank you :-) But I see null value when I call the same function in query
? There is no function above. It is a datatype called Long.
If you can see my function in the question section
0

Byte is suitable for your function defined

SELECT CC1([BP],[CC]) as n

Function CC1(BP As Byte, CC As Byte) As String
    If BP = 1 Then
    CC1 = "B*"
      Else
    CC1 = "C*"
   End If
End Function

Note:

  1. The value to be returned must be assigned to a variable having the same name as the Function
  2. CC As Byte is not used.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.