Results 1 to 5 of 5
  1. #1
    Sheba is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    239

    Exclamation Login form

    hi, I'm having a bit of trouble with representing this query in Access:



    SELECT tblUser.UserID, [LastName] & "," & [FirstName] AS Fullname
    FROM tblUser
    ORDER BY tblUser.LName, tblUser.FName;

    In Query design it looks like the table below but I get an error saying that my expression has invalid syntax. Could you point out what I'm doing wrong here please? I can't seem to pick it out. Maybe been staring at the screen for too long..?

    The UserID combo box only shows the LastName with the comma


    Field UserID Expr:1 [LastName] & "," FullName: & [FirstName]
    Table tblUser






    Any help is greatly appreciated!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Why are the field names inconsistent? Which is correct:

    FName or FirstName

    LName or LastName
    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
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    Build the query using query Design View rather than attempt to construct sql free form....once the query works the way you want it - then change it to SQL View and it will give you the syntax. This is one of the great aspects of the Access product.

  4. #4
    Sheba is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    239
    hey thanks June7 and NTC. I've fixed this one. The correct syntax below. I took out the square brackets

    SELECT UserID, Lastname & “, ” & Firstname AS Fullname
    FROM tblUser
    ORDER BY Lastname, Firstname;

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    The brackets don't hurt and are in fact required if field and object names have spaces or special characters/punctuation (underscore is exception). Access will actually throw them into the SQL if you don't. But beware, sometimes Access won't recognize the name and will enclose in " marks. This can happen in expressions.
    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.

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

Similar Threads

  1. Replies: 3
    Last Post: 03-17-2014, 10:23 AM
  2. Login Form
    By greatopoo in forum Programming
    Replies: 1
    Last Post: 12-02-2012, 03:13 PM
  3. Login Form
    By data808 in forum Forms
    Replies: 1
    Last Post: 08-23-2012, 04:48 PM
  4. Replies: 1
    Last Post: 12-11-2011, 11:48 AM
  5. Login form with nt login
    By hitesh_asrani_j in forum Forms
    Replies: 6
    Last Post: 09-22-2011, 11:43 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