Results 1 to 6 of 6
  1. #1
    DubCap01 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Location
    Dubbo, Australia
    Posts
    104

    DLookup 2nd character in a text string

    Hi all,

    I have a table TblGuests, with two text fields, GuestID (number) and PIN (text). Field PIN can only contain 4 characters.
    I need a DLookup something like this:



    =DLookup ("only the 2nd character of the string in PIN", "TblGuests","GuestID = Forms!FrmConfirm!GuestID")

    Is this possible, or should I be looking at another way of retrieving it?

    thanks in anticipation
    Pete

  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
    Perhaps Mid (PINField,2,1)

    see this for syntax and examples
    Last edited by orange; 02-09-2015 at 09:15 AM. Reason: After seeing Johns post I see the field I had was incorrect.

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Try:

    =DLookup ("mid(PIN,2,1)", "TblGuests","GuestID = Forms!FrmConfirm!GuestID")

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I'd think you'd run Mid() against the DLookup:

    =Mid(DLookup("PIN", "TblGuests","GuestID = " & Forms!FrmConfirm!GuestID), 2,1)

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    DubCap01 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Location
    Dubbo, Australia
    Posts
    104
    Thanks MissingLinq, all fixed

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad you got it working!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. How do I return last character in a string?
    By SSgtBarry in forum Queries
    Replies: 4
    Last Post: 06-22-2014, 08:10 PM
  2. Replies: 6
    Last Post: 06-07-2013, 09:45 AM
  3. Add character's to text box
    By Joopster in forum Forms
    Replies: 1
    Last Post: 03-20-2013, 06:45 PM
  4. Replies: 3
    Last Post: 12-22-2012, 05:33 PM
  5. # added to string with Dlookup
    By normever in forum Programming
    Replies: 1
    Last Post: 02-27-2009, 10:52 AM

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