Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Posts
    6

    Unanswered: Getting Data to a Text Box with a Query.

    I am trying to populate a text box on a form using a select statement on the “On Current” event of the form.

    I am not sure if I can do this or not, as I have not attached a record source to this form.

    The statement looks like this:
    CountOfQuantity = "SELECT count(*) FROM [Join Tables for QA Info] where quantity = “1””

    When I execute the form, it just puts the statement as a literal into the form. Meaning the written select statement is in the text box.

    So, am I way off in doing this with an Event Procedure, or is there an easier way.

    Lastly, I want to do this from multiple tables against multiple data sets to provide a statistics “Dashboard if you will” display that is calculated upon opening the form or clicking the refresh button.

  2. #2
    Join Date
    Jul 2004
    Posts
    125
    You must use DAO or ADO to run the query and extract the desired information. Then you assign the output to the textbox. Me!Textbox = query result.

  3. #3
    Join Date
    Jul 2004
    Location
    Southampton, UK
    Posts
    368
    Quote Originally Posted by kylev
    So, am I way off in doing this with an Event Procedure, or is there an easier way.
    If you want a count of records based on a given criteria to be displayed in a text box you could try using the DCount function:

    =DCount("[Quantity]","myJoinQuery","[Quantity]=1")

    Place it in the control source property of your text box.

    HTH
    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •