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 / Forms Programming / April 2005

Tip: Looking for answers? Try searching our database.

Pick the larger of 2 text fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
latraille - 05 Apr 2005 04:11 GMT
I want to create a text field which is the larger of 2 existing text fields.  
If I try to use the IIf function to compare the Len() of each field the
result can not be the larger text field.  It appears that the IIf function
value must be some form of a number.  My exact need can be expressed this way
-  Assume you have 2 Text Fields A and B and that the text field C is the
result of the following:  If B is not null then C = B else C = A.  This
should be very simple but the the fact that these are all text fields is
causing problems.  Any help would be appreciated,
Arvin Meyer - 05 Apr 2005 04:25 GMT
First write a function (aircode):

Public Function Foo(A As String, B As String) As String
On Error Resume Next
If Len(A & vbNullString) > Len(B & vbNullString) Then
   Foo = A
Else
   Foo = B
End Function

Now use it in a query column:

C: Foo([Field A], [Field B])
Signature

Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

> I want to create a text field which is the larger of 2 existing text fields.
> If I try to use the IIf function to compare the Len() of each field the
[quoted text clipped - 4 lines]
> should be very simple but the the fact that these are all text fields is
> causing problems.  Any help would be appreciated,
 
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.