I am new to VBA
Question: what is the code to replace a value in a field.
eg
Let the field name to be "Fruit"
Banana to "Null"
Papaya to Apple
Note : I am Using this code in a report
Any solutions?
Thanks in advance
Kennykee
tina - 03 May 2005 08:06 GMT
try
Select Case Me!Fruit
Case "Banana"
Me!Fruit = Null
Case "Papaya"
Me!Fruit = "Apple"
End Select
hth
> I am new to VBA
>
[quoted text clipped - 13 lines]
>
> Kennykee
Tim Ferguson - 03 May 2005 17:49 GMT
> Question: what is the code to replace a value in a field.
> Note : I am Using this code in a report
I don't think you can change the value of the field in a report: in any
case I don't think you'd want to. Set the Controlsource of the textbox to
a custom function that you are about to write:
= RenameFruit([Fruit])
Then put this sort of thing in the Report module:
' rename the fruit
' note the use of variants so it does not
' fall over with the use Nulls
'
Public Function RenameFruit(SomeFruit As Variant) _
As Variant
If IsNull(SomeFruit) Then
RenameFruit = Null
Else
Select Case SomeFruit
' etc as suggested by Tina
Case "banana" : RenameFruit = Null
Case "papaya" : RenameFruit = "Apple"
Case Else : RenameFruit = "Yum, yum, something new!"
End Select
End If
End Function
Hope that helps
Tim F