Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    287

    Unanswered: Sub Form and Queries

    I have a main form and a subform that have no record selected.
    The main form has a combo box that updates the subform using a query (based on name selected). This works fine.

    I then added the ability to sue this same query in VBA uo pull data using DLOOKUP into some unbound boxes on the subform, so Day1, Day2, Day3 displays information from the selected table in the query.

    Behind the scenes the query runs as it should, pulls the appropriate records for the selected name, but the problem is that only Day1 on the subform displays the infromation. Even though the query shows data for Day2, Day3, etc it is not shown.

    Do I need to do anything to my forms/subforms to get this to work. I have tested using just Day2 or Day3 and this works fine, but again only one record is shown at a time.

    Please Help!

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    I'm not sure to understand. However, if Day1, Day2, Day3 are values from a column on different rows of the data set returned by the query, this is normal: without any proper criteria, DLookUp() returns data from an arbitrarily selected row in the domain (usually the first but it's not garanteed). From http://office.microsoft.com/en-us/ac...01228825.aspx:
    The DLookup function returns a single field value based on the information specified in criteria. Although criteria is an optional argument, if you don't supply a value for criteria, the DLookup function returns a random value in the domain.
    Please explain how the query is built (SQL statement) and also the line of code where the DLookUp function is used.
    Have a nice day!

  3. #3
    Join Date
    Mar 2004
    Posts
    287
    thanks, but i just found it - date criteria (part of the dlookup) had to be set to US not UK. Thanks.

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Quote Originally Posted by NeilMansell View Post
    thanks, but i just found it - date criteria (part of the dlookup) had to be set to US not UK. Thanks.
    You're welcome!
    Have a nice day!

Posting Permissions

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