Numbering against text

syedadnan

Access Lover
Local time
Tomorrow, 01:05
Joined
Mar 27, 2013
Messages
315
Regards,

I am having a query which having a category field like Electrical, Sports, House hold etc.

What i want that if i select Electrical then it should return 15, if Sports then 10 and so on i think this could be done through this below menitoned VBA but it need change from integar to text... any help

Option Compare Database

Public Function fncGrade(intNum%) As String
Select Case intNum
Case 0 To 1: fncGrade = "Same as Previous"
Case 2 To 32: fncGrade = "C-3"
Case 33 To 40: fncGrade = "C-2"
Case 41 To 50: fncGrade = "C-1"
Case 51 To 60: fncGrade = "B-3"
Case 61 To 70: fncGrade = "B-2"
Case 71 To 80: fncGrade = "B-1"
Case 81 To 90: fncGrade = "A-2"
Case 91 To 100: fncGrade = "A-1"
Case Else:: fncGrade = "X-X"
End Select
End Function
 
Sounds like what you want is a lookup table not a function like this
 
Depends on what your purpose is, but a simple one might be
NR Description
15 Electrical
10 Sports
etc.
 
Is this what you want ?
Code:
Public Function fncGrade(Category as string) As String

Select Case Category
  Case "Electrical": fncGrade = "Same as Previous"
  Case "Sports": fncGrade = "C-3"
  Case "House hold": fncGrade = "C-2"
  Case Else:: fncGrade = "X-X"
End Select

End Function
 
Is this what you want ?
Code:
Public Function fncGrade(Category as string) As String

Select Case Category
  Case "Electrical": fncGrade = "Same as Previous"
  Case "Sports": fncGrade = "C-3"
  Case "House hold": fncGrade = "C-2"
  Case Else:: fncGrade = "X-X"
End Select

End Function



Absolutely perfect....

Thanks a billion
 

Users who are viewing this thread

Back
Top Bottom