I am trying to write a function that will perform different calculations based on a Log Code. The function is returning an error of undefined external name. I think that I need to open a recordset, but I do not know how to do this. Any help would be great. The table that I need to pull from is called SMOG Process. The field names are there as well.
Public Function fexcess(LogisticsCode)
If LogisticsCode = "I" Then
fexcess = 0
ElseIf LogisticsCode = "A" Then
fexcess = [SMOG Process]![Total Inventory UOM] - [SMOG Process]![Customer Orders] - [SMOG Process]![SSC Allocated]
ElseIf LogisticsCode = "2" Then
fexcess = [SMOG Process]![Total Inventory UOM] - [SMOG Process]![Customer Orders] - [SMOG Process]![SSC Allocated]
ElseIf LogisticsCode = "D" Then
fexcess = [SMOG Process]![Total Inventory UOM] - [SMOG Process]![Customer Orders] - [SMOG Process]![SSC Allocated]
ElseIf LogisticsCode = "M" Then
fexcess = [SMOG Process]![Total Inventory UOM] - [SMOG Process]![Customer Orders] - [SMOG Process]![SSC Allocated]
ElseIf LogisticsCode = "O" Then
fexcess = [SMOG Process]![Total Inventory UOM] - [SMOG Process]![Customer Orders] - [SMOG Process]![SSC Allocated]
ElseIf LogisticsCode = "P" Then
fexcess = [SMOG Process]![Total Inventory UOM] - ([SMOG Process]![12 Month Weekly Sales] * 52) - [SMOG Process]![SSC Allocated] - [SMOG Process]![Customer Orders]
ElseIf LogisticsCode = "K" Then
fexcess = [SMOG Process]![Total Inventory SF] - ([SMOG Process]![12 Month Weekly Sales] * 52) - [SMOG Process]![SSC Allocated] - [SMOG Process]![Customer Orders]
ElseIf LogisticsCode = "C" Then
fexcess = [SMOG Process]![Total Inventory UOM] - ([SMOG Process]![12 Month Weekly Sales] * 52) - [SMOG Process]![SSC Allocated] - [SMOG Process]![Customer Orders]
ElseIf LogisticsCode = Null Then
fexcess = [SMOG Process]![Total Inventory UOM] - [SMOG Process]![Customer Orders] - [SMOG Process]![SSC Allocated]
End If
End Function