Create a procedure to evaluate two alphanumberic fields and then manipulate

  • Thread starter Thread starter Desilu via AccessMonster.com
  • Start date Start date
D

Desilu via AccessMonster.com

How would I convert the below query IIF statement to a procedure?

Basically I'm working with an alpha numberic field that so far has had either
numbers or characters stored within. Also, based on the value of the field,
I do have to add a value from another field. In the end the field is of
course formatted as text.

MyGroupNum:

Trim(IIf([Group Num]="0000001000",Str(Val([group num])+Val([account num])),
IIf([Group Num]="0000002000",Str(Val([group num])+Val([account num])),
IIf(Left([group num],1)<>"0",[group num],
IIf(Len(Val([group num]))=3,"0" & Val([group num]),Val([group num]))))))

Thank you in advance.
Desilu
 
Function fReturnMyGroupNum(FldOne,FldTwo) as String
IF FldOne ="0000001000" Or FldONe = "0000002000" then
fReturnMyGroupNum = Val(FldOne) & Val(fldTwo)
ELSEIf FldOne Like "0*" Then
fReturnMyGroupNum =FldOne
ElseIf Len(Val(FldOne))>3 Then
fReturnMyGroupNum = "0" & Val(FldONe)
Else
fReturnMyGroupNum =Val(fldOne)
end if

End Function

If fldOne is ever null, you might get an erroroneous return.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
John,

Thank you SO much! I tweaked the code a bit and it works great! You made my
day :)

Desilu

John said:
Function fReturnMyGroupNum(FldOne,FldTwo) as String
IF FldOne ="0000001000" Or FldONe = "0000002000" then
fReturnMyGroupNum = Val(FldOne) & Val(fldTwo)
ELSEIf FldOne Like "0*" Then
fReturnMyGroupNum =FldOne
ElseIf Len(Val(FldOne))>3 Then
fReturnMyGroupNum = "0" & Val(FldONe)
Else
fReturnMyGroupNum =Val(fldOne)
end if

End Function

If fldOne is ever null, you might get an erroroneous return.
How would I convert the below query IIF statement to a procedure?
[quoted text clipped - 15 lines]
Thank you in advance.
Desilu
 
Back
Top