Results 1 to 4 of 4
  1. #1
    Nofri is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2021
    Posts
    7

    Display Text Box From SQL Result

    Hi



    I need help, i want to display Text Box Unbound from my query
    this is my query

    SELECT Name AS Expr1
    FROM Username
    WHERE (Username.UserName)=GetLogonName();

    what should i do to make this query result into form?
    because i change control source in Unbound Textbox properties the result is error

    Thankyou

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    1,742
    If it is a single text box use a DLookup

    = DLookup("[Name]","UserName","UserName = '" & GetLogonName() & "'")

    Note that Name is a bad choice of field name as it is a reserved name. As is UserName - it's a Environ() Function.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Nofri is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2021
    Posts
    7
    the Expression You Entered Contains Invalid Syntax
    they said invalid character or comma or you entered text without surrroundin it in quotation marks

    Let Me Change the SQL become like this

    SELECT Name AS Login
    FROM Table1
    WHERE (Table1.UserName)=GetLogonName();

  4. #4
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    1,742
    Open the VBA editor and type the following into the immediate window (Press ctrl + G to display it)

    ? GetLogonName ()

    What does it return?

    Then try this in the immediate window

    ? DLookup("[Name]","Table1","UserName = '" & GetLogonName() & "'")

    Does that SQL Query return a result?


    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. Display result when data missing
    By roarcrm in forum Queries
    Replies: 5
    Last Post: 08-01-2014, 08:27 PM
  2. Replies: 1
    Last Post: 07-03-2014, 08:27 PM
  3. Qyery result to display on form
    By keiath in forum Forms
    Replies: 5
    Last Post: 02-15-2014, 06:50 PM
  4. Display Query Form as a Result
    By rescobar in forum Forms
    Replies: 2
    Last Post: 08-19-2013, 11:31 AM
  5. HELP! Display a query result into form
    By leanne in forum Forms
    Replies: 15
    Last Post: 06-23-2010, 09:18 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 - Senior Forums