Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Public Funtion Error

Status
Not open for further replies.

lars7

Technical User
Aug 16, 2005
817
GB
Hi Guys,
Can anyone help me with this one.

I have the following "Public Function" to put the word "Band" before a number in a report:

Public Function GetOrdinal2(lngItem As Long) As String
Dim intOnesDigit As Integer
Dim strReturn As String
Dim intTemp As Integer

intTemp = lngItem Mod 100
If intTemp <= 10 Then
strReturn = "Band "
End If
GetOrdinal2 = strReturn & lngItem
End Function

but number 8 has a letter after it like: 8A, 8B, 8c, or 8D.
At the moment it is showing as "error"

Thanks in advance.
 
Use the Val function

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for the advise PH but wouldn't know where to start with that.
 
Hi,
Found this and had a go but I am only getting the number, no word "band" and still the error:

Public Function GetOrdinal2(lngItem As Long) As String
Dim intOnesDigit As Integer
Dim strReturn As String
Dim intTemp As Integer

intTemp = lngItem Mod 100
If intTemp = Val("&ABCD") Then
strReturn = "Band "
End If
GetOrdinal2 = strReturn & lngItem
End Function
 
I suggested you to use the Val function when calling GetOrdinal2, not inside it !
A starting point:
x = GetOrdinal2(Val("8B"))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PH,
Sorry, wasn't really following what you where meaning and I'm still too sure. :~/ This is the way that I call the function in the report so could you show me how would I add your bit to that.

=GetOrdinal2([Band])
 
Hi PH,
I went a different way with this one. I put a "Band" label in the detail next to the field Band. Thanks as always for your time.
 
I suggested simply this:
=GetOrdinal2(Val([Band]))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top