Results 1 to 5 of 5
  1. #1
    amc1902 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Oct 2014
    Posts
    10

    Displaying a Query result in a text box

    Hello all,

    I'm new to the world of access but learning a little more each day!

    I have a command button (Case received within period) that runs a query (qrydaterec) without any problem and displays it in a data field view. What I woud like is to display the result in a text box (textbox 68) which sits alongside the command button which runs the query.



    I've searched the forum and it seems that the =DLookUp ("Field name","Query name") could be what I'm looking for. The only issue is, I'm not sure where this command would be placed. Could anyone advise? Alternatively, would there be an alternative available that could achieve this result?


    Many thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    If you want to update 1 text box then on the button _Onclick event:

    txtBox =DLookUp ("[Field name]","qryDaterec")

  3. #3
    amc1902 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Oct 2014
    Posts
    10
    Hi, many thanks for your reply. The _Onclick event for the button launches the query therefore it is already populated. Am I able to add your command to this, in effect having two commands for the _Onclick event?

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you can plug in as many cmds or vb code in the SUB BTN_ONCLICK() event as you want.

  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,770
    What do you mean by 'launches the query'? A SELECT query doesn't need to be 'run' or 'launched' - just reference the query in the DLookup or open form or report bound to the query.

    Unless the query has dynamic parameters - that could complicate. I never use dynamic parameters in query.
    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. Text box show result of query
    By Ash in forum Access
    Replies: 2
    Last Post: 08-06-2014, 03:00 PM
  2. displaying query result as a subform
    By uzair_rosli in forum Access
    Replies: 4
    Last Post: 02-26-2013, 04:29 AM
  3. Replies: 1
    Last Post: 01-06-2013, 01:47 PM
  4. show a query result in a text box
    By mikael in forum Access
    Replies: 2
    Last Post: 09-13-2012, 02:17 AM
  5. Replies: 1
    Last Post: 09-28-2011, 09:48 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