adding middle initial field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eneyardi
    New Member
    • Jul 2010
    • 180

    adding middle initial field

    I want to add the middle initial field in contacts extended query.
    Code:
    File As: IIf(IsNull([Last Name]),IIf(IsNull([First Name]),[Company],[First Name]),IIf(IsNull([First Name]),[Last Name],[Last Name] & ", " & [First Name]))
    where can i put [middle initial] so that when i view the report the complete name will appear. ex. Juan c. Dela Cruz
    Last edited by NeoPa; Jan 12 '12, 06:30 PM. Reason: Added mandatory [CODE] tags for you
  • eneyardi
    New Member
    • Jul 2010
    • 180

    #2
    it works, I only add after [first name]&" "&[Middle Initial]&" "&[last Name]
    Code:
    Contact Name: IIf(IsNull([Last Name]),IIf(IsNull([First Name]),[Company],[First Name]),IIf(IsNull([First Name]),[Last Name],[B][First Name] &" " & [Middle Initial] & " "  & [Last Name][/B]))
    Last edited by NeoPa; Jan 12 '12, 06:31 PM. Reason: Added mandatory [CODE] tags for you

    Comment

    • sierra7
      Recognized Expert Contributor
      • Sep 2007
      • 446

      #3
      Hi,
      You seem to have fixed this to your satisfaction but you will always have two spaces between first and lastname.

      In your example you had a fullstop (dot, punto, perĂ­odo) after the middle initial, so you may want to do something like ;-

      Code:
       .....
      ,[first name]& IIF(IsNull[Middle Initial]," "," " & [Middle Initial] & ". ") & [Last Name].....
      S7

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32663

        #4
        Firstly, Please read the PM I sent carefully. It may be your final warning. Any discussion of such must be via PM.

        As for your question, I will ignore the [Company] field as the logic for that isn't explained anywhere, but assuming you want to display the optional [First Name], followed by the optional [Middle Initial] followed by the mandatory [Last Name], you could try :
        Code:
        Contact Name: ([First Name] + ' ') & ([Middle Initial] & '. ') & [Last Name]
        See Using "&" and "+" in WHERE Clause for more on how this works.

        Comment

        • eneyardi
          New Member
          • Jul 2010
          • 180

          #5
          Thanks sierra7, thanks neopa. sorry again, i thought it doesn't need to be tag.

          Comment

          • eneyardi
            New Member
            • Jul 2010
            • 180

            #6
            it became double period the middle initial after i used your code neopa

            Code:
            Contact Name: ([First Name] + ' ') & ([Middle Initial] & '. ') & [Last Name]
            it became like this: Juan C.. Dela Cruz

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32663

              #7
              Originally posted by eneyardi
              eneyardi:
              it became like this: Juan C.. Dela Cruz
              That tells me that your [Middle Initial] field has been populated with (includes) the period. This is not good design. The period is not (should not be) part of the data.

              Originally posted by NeoPa
              NeoPa:
              Assuming you want to display the optional [First Name], followed by the optional [Middle Initial] followed by the mandatory [Last Name], you could try :
              Code:
              Contact Name: ([First Name] + ' ') & ([Middle Initial] & '. ') & [Last Name]
              See Using "&" and "+" in WHERE Clause for more on how this works.
              The best idea is to fix your data. However, while the data is still broken simply use the following instead :
              Code:
              Contact Name: ([First Name] + ' ') & ([Middle Initial] & ' ') & [Last Name]
              Last edited by NeoPa; Jan 16 '12, 04:33 PM. Reason: To include the actual (main) answer in the post selected for Best Answer.

              Comment

              • eneyardi
                New Member
                • Jul 2010
                • 180

                #8
                Thanks Neopa, i fixed my data not to include period.

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32663

                  #9
                  That's very sensible :-) You seem to be learning since you've been using Bytes.

                  Comment

                  Working...