Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / May 2005

Tip: Looking for answers? Try searching our database.

Very Simple Question!!!!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kennykee - 03 May 2005 06:56 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.