Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    brownk is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    May 2012
    Location
    Evansville, IN
    Posts
    56

    "Trimming down" the name field?


    Hello everyone! In my database i have a field that contains the username of whoever entered the data. It is listed as THISNAME/FirstnameLastname. What could i do to get the query to return only the FirstnameLastname and ignore the THISNAME/ ?
    Thanks
    Last edited by brownk; 05-16-2012 at 02:55 PM.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Use string manipulation functions. Will there always be the one slash character?

    Mid([fieldname],InStr([fieldname],"/")+1)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    brownk is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    May 2012
    Location
    Evansville, IN
    Posts
    56
    Yes, It will always be in that format

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Did it work?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    brownk is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    May 2012
    Location
    Evansville, IN
    Posts
    56
    No it returns everything

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    It is returning the full string? Show your attempted query sql statement. Provide sample of actual data.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    brownk is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    May 2012
    Location
    Evansville, IN
    Posts
    56
    Mid([firstLast],InStr([firstLast],"/")+1) This is within the criteria field. It returns THISNAME/FirstnameLastname
    Last edited by brownk; 05-16-2012 at 02:54 PM.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    The expression is intended to be in the Field row to create a field. Then you can apply criteria to that constructed field.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    brownk is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    May 2012
    Location
    Evansville, IN
    Posts
    56
    Its now in the field row and still returning the same results.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Show the sql statement for analysis.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    brownk is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    May 2012
    Location
    Evansville, IN
    Posts
    56
    Mid([firstLast],InStr([firstLast],"/")+1) AS [First Last]

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    The query looks fine. Are you saying that the constructed field [Primary Officer] does not show FirstnameLastname part extracted from the original string?

    I tested the string manipulation functions on a string with the example structure and it does work.

    If you still need help I will have to analyse the project. Follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    brownk is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    May 2012
    Location
    Evansville, IN
    Posts
    56
    Yes the full field still shows. It does not extract the FirstnameLastname part.

  14. #14
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    I have no explanation for why that isn't working. As stated, will have to review project and data directly if you want to provide.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    Gary Frazier is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Posts
    15
    Quote Originally Posted by brownk View Post
    Yes the full field still shows. It does not extract the FirstnameLastname part.
    This is just a suggestion as to how I do it. I capture their log in when they add an entry into the database. Sometimes it is good to know who did what.
    Add 2 fields to your table
    CreatedByUser Text
    CreatedDate Date/Time


    Copy this in a module
    I named mine this
    Module name (basMyEmpID ) Module
    Option Explicit
    Option Compare Database
    Public lngMyEmpID As Long

    Add the fields anywhere on your form
    And put this in the forms Load event
    This is just a suggestion as to how I do it. I capture their log in when they add an entry into the database. Sometimes it is good to know who did what.
    Add 2 fields to your table
    CreatedByUser Text
    CreatedDate Date/Time


    Copy this in a module
    I named mine this
    Module name (basMyEmpID ) Module
    Option Explicit
    Option Compare Database
    Public lngMyEmpID As Long

    Add the fields anywhere on your form
    And put this in the forms Load event
    Private Sub Form_Load()
    Me!CreatedByUser = Environ("username")
    Me!CreatedDate = Now
    End Sub

    It saves back to the database.
    Just a suggestion!!!


    Private Sub Form_Load()
    Me!CreatedByUser = Environ("username")
    Me!CreatedDate = Now
    End Sub

    It saves back to the database.
    Just a suggestion!!!


Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 03-29-2012, 02:32 PM
  2. Replies: 1
    Last Post: 03-03-2012, 10:17 PM
  3. Replies: 8
    Last Post: 08-05-2011, 02:55 PM
  4. Replies: 16
    Last Post: 07-22-2011, 09:23 AM
  5. "Group By" causes "ODBC--Call Failed" error
    By kaledev in forum Queries
    Replies: 1
    Last Post: 03-09-2011, 02:43 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