Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2015
    Posts
    17

    help with writing a function that returns only the initials of a name input in a textbox

    Hi everyone,
    I'm trying to write a code that when the user inputs their name for example John J Rodriguez and press the cmdInitials buttom will return only the initials in uppercase JJR. The code that I wrote gives me the following error: the expression on click you entered produce the following error: Procedure declaration doesn't match description on event or procedure having the same name. Also my other bottoms were working fine until I added this portion of the code, now it's giving me the same error for all.Can anyone help me?? I have attach the form please help me i'm new to coding. Thank you
    240CCA04.zip

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Suggest you change your button click event to
    Code:
    Private Sub cmdInitials_Click()  'removed the parameter
    
    'dim all your variables
        Dim i As Integer
        Dim strNames As Variant
        Dim strInput As String
        Dim strOutput As String  '<--had to Dim this
        strInput = Me.txtInput ' <---need to assign the value from the textbox
        strNames = Split(strInput, " ")
    
        For i = LBound(strNames) To UBound(strNames)
            strOutput = strOutput & UCase(Left(strNames(i), 1)) '<---changed input to output removed the trailing space
        Next i
       
    lblOutPut.Caption = strOutput  '<---------------what is strOutput??
    End Sub
    You did not dim strOutput. You used strInput in the For loop

    Note: I just got the initials button to do what I think you wanted.
    Attached Thumbnails Attached Thumbnails ccaroline.jpg  
    Last edited by orange; 01-31-2015 at 06:12 PM.

  3. #3
    Join Date
    Jan 2015
    Posts
    17
    Than you for helping me with my code Orange

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Happy to help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 05-22-2014, 05:58 AM
  2. Val function returns #error on text/percentage
    By allenjasonbrown@gmail.com in forum Queries
    Replies: 1
    Last Post: 06-23-2013, 08:24 AM
  3. Replies: 6
    Last Post: 02-27-2013, 04:43 PM
  4. need a formula function Name to Initials
    By techexpressinc in forum Queries
    Replies: 2
    Last Post: 09-17-2010, 12:37 PM
  5. Writing data from textbox to table
    By mll in forum Forms
    Replies: 4
    Last Post: 03-10-2010, 05:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums