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])
Erik A
  • 31,639
  • 12
  • 42
  • 67
Archana
  • 37
  • 6

3 Answers3

2

VBA doesn't have a data type short.

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

Andre
  • 26,751
  • 7
  • 36
  • 80
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?

QHarr
  • 83,427
  • 12
  • 54
  • 101
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.
Santosh
  • 12,175
  • 4
  • 41
  • 72