Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2005
    Posts
    67

    Unanswered: Displaying results of a query in a textbox (form)

    I know this should be easy, but can anyone tell me how I can display the results of a query in a form (textbox) using vba. I've tried everything I know from using the 'properties' window to just plain trying to hard code it but nothing is working. Please help!

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    What is the nature of the data returned by the query?
    (3 columns, 1 row; 1 column, 4 rows; or just 1 piece of data)
    Inspiration Through Fermentation

  3. #3
    Join Date
    Dec 2005
    Posts
    67
    Okay - what it is, is that I've designed a questionnaire - so there's one text box and 3 checkboxes. All I want to is for the results of a query to populate the text box with the question. So say there are 5 questions in a table, I want each textbox to be populated with a question from the table.

    When I use the properties window to link the textbox to the table - it populates the textboxes with the same question.

    Is this clear enough for you? So to answer your question, the first questionnaire has 11 textboxes i.e. 1 column, 11 rows ...

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    just for fun (before i go to watch the footie).

    an A query can return Error, Null, 1 row (N fields), 2.4billion rows (N fields)
    ...how could Mr Gates display query returns in a text box without knowing what the 'shape' of the return is?

    either

    you use a list (or combo) and set your query as .rowsource (handles most cases mentioned above)

    or

    you use a domain aggregate function that will return you a single value (or Null) that could reasonably be displayed in a textbox, as in:
    myTextBox = dXXXXXXX("myFieldName", "myTableOrQueryName", "ID = 1")
    check out dlookup, dmax etc etc in help and on this site (and don't forget the quotes).

    WARNING gurus here will despise you if you use domain aggregate functions: ignore them if d-a funcs suit what you are trying to achieve.

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    crossed-post: use a list and forget d-a

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Dec 2005
    Posts
    67
    Thanks. I'll get back to you for any clarification.

  7. #7
    Join Date
    Dec 2005
    Posts
    67
    Thanks for your help so far but is there just no way I can display the result set of a query in a series of textboxes? The list and combo thing works but doesn't suit the design of the form as what the client wants to see is a list of 'displayed questions' with check boxes next to them similar to what you'd see on, for instance, a survey. Is this possible?

  8. #8
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    I've read your post multiple times, and it looks to me like your looking to display survey results in a format like:

    Code:
    Question                       Yes    No   Sometimes
    ---------                      ----   ---   ---------
    Do You Eat Meat?                                X
    Do You Like Pizza?            X
    Do you own a cat?                   X
    Is that about right?
    Inspiration Through Fermentation

Posting Permissions

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