IN Theory, Not tested.
Code:
Public Function GetCustPrice(ByVal strCustomer As String)
On Error GoTo Err_GetCustPrice
Dim inWtCode As Integer ' declare variable to store WT Code in
intWtCode = DLookup("[Wt Code]", "[Main Table]","[Cust#]='" & strCustomer & "'") ' Get the WT Code and store in intWTCode
' Return the associated field with Wt Code, If there isn't one return 0
GetCustPrice= Nz(DLookup("[" & intWtCode & "]", "[Main Table]", "[Cust#]='" & strCustomer & "'"), 0)
Safe_GetCustPrice:
Exit Function
Err_GetCustPrice:
Debug.Assert Err.Number <> 0
Resume Safe_GetCustPrice
End Function