Results 1 to 5 of 5
  1. #1
    Darkmatter5 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2012
    Posts
    11

    Help with populating Form Detail section with query results

    I have a query:


    Code:
    SELECT dbo_jobs.JobID, dbo_jobs.JobNumber, dbo_jobs.JobDescription, dbo_jobs.JobLocation, dbo_subdivisions.SubdivisionName, dbo_jobs2surveys.SurveyID
    FROM dbo_subdivisions INNER JOIN (dbo_jobs INNER JOIN dbo_jobs2surveys ON dbo_jobs.JobID = dbo_jobs2surveys.JobID) ON dbo_subdivisions.SubdivisionID = dbo_jobs.SubdivisionID
    WHERE (((dbo_jobs2surveys.SurveyID)=[Forms]![Search Form]![cb_Survey]));
    I have a form that consists of a combobox "cb_Survey", a button that applies the forms filter and a detail section that I need to populate with the results from the query. Here is the code run by the button.

    Code:
    Private Sub btn_RunQuery_Click()
        lb_SearchStatus.Caption = "Search results for the survey of " & Me.cb_Survey
        Me.Filter = "([SurveyID]='" & Me.cb_Survey & "')"
        Me.FilterOn = True
    End Sub
    When the button is clicked the label is updated, but nothing happens to the detail area.

    The form's "Record Source" is set to the query and the "Control Source" of the items in the detail section are set to the appropriate fields from the query set in the form's "Record Source".

    I'm lost, please help!

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Welcome to the forum!

    I would remove the WHERE clause from the query since you are filtering the results using the code.
    Is the surveyID field a numeric datatype or a text datatype?

  3. #3
    Darkmatter5 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2012
    Posts
    11
    Quote Originally Posted by jzwp11 View Post
    Welcome to the forum!

    I would remove the WHERE clause from the query since you are filtering the results using the code.
    Is the surveyID field a numeric datatype or a text datatype?
    SurveyID is numeric, int.
    I also removed the WHERE clause. the query is now.
    Code:
    SELECT dbo_jobs.JobID, dbo_jobs.JobNumber, dbo_jobs.JobDescription, dbo_jobs.JobLocation, dbo_subdivisions.SubdivisionName, dbo_jobs2surveys.SurveyID
    FROM dbo_subdivisions INNER JOIN (dbo_jobs INNER JOIN dbo_jobs2surveys ON dbo_jobs.JobID = dbo_jobs2surveys.JobID) ON dbo_subdivisions.SubdivisionID = dbo_jobs.SubdivisionID;
    I'm now getting the following error.
    "Run-time error '3464': Data type mismatch in criteria expression."

    What exactly does "Me.cb_Survey" return? Is it the value column of the combobox? When I created the combobox, I opted to hide the ID field.

    Thanks for the warm welcome!

  4. #4
    Darkmatter5 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2012
    Posts
    11
    Figured it out, SurveyID is an int, so I don't need the single quotes denoting that it's a string. Thanks for getting my brain synapses firing!

  5. #5
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Glad you got it worked out!

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

Similar Threads

  1. Columns in Report Detail Section only
    By gg80 in forum Reports
    Replies: 10
    Last Post: 08-03-2014, 07:41 PM
  2. Replies: 6
    Last Post: 06-20-2012, 06:42 AM
  3. Count in detail section of a report
    By ccordner in forum Reports
    Replies: 9
    Last Post: 02-08-2012, 06:55 AM
  4. The length of detail section of a report
    By blueraincoat in forum Reports
    Replies: 2
    Last Post: 04-06-2011, 12:24 AM
  5. Replies: 1
    Last Post: 10-11-2009, 08:31 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