Results 1 to 4 of 4
  1. #1
    mar_t is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    52

    How to set a query field a combo box

    Good,


    I already created my query table and I would like to know on how to set a query field [Section] in a combo box in my form. The combo box will used to filter records (based on Section) in my tblEmployee and be able to print that filtered data using my report form.

    Please help.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Are you asking how to use the combo as a query criteria? Right click and select Build, which will let you point to it. It will end up looking like:

    Forms!FormName.ComboName
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    mar_t is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    52
    Yes.
    I build the code as you mentioned, however it keeps on poping out everytime I use the combo box.

    I found a code from the net (Google search), did some modifications and use it. It worked but the report is blank (no data) and contains only the report headers. What I want is that whenever I select a Section name in my combo box it would print only the records (w/ 7 fields) based on the selected value. Below is my code. I really appreciate if you could help me on this one.

    Thank you.

    Code:
    Private Sub Combo0_Click()
    Dim strwhere As String
    strwhere = " [Section]= ' " & Combo0 & "'"
    DoCmd.OpenReport "rptAllStaffReport", acViewPreview, , strwhere
    End Sub

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    How does it work without the extra spaces?

    strwhere = "[Section]= '" & Me.Combo0 & "'"

    I assume Section is a text data type? Does the bound column of Combo0 contain the expected value, or a numeric key value?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Combo Box - Field List Values
    By jennyaccord in forum Forms
    Replies: 5
    Last Post: 07-29-2011, 01:49 PM
  2. auto populate combo field?
    By myboii in forum Access
    Replies: 8
    Last Post: 07-09-2010, 05:46 AM
  3. Replies: 6
    Last Post: 06-29-2010, 09:56 PM
  4. Combo Box field selection help needed
    By techexpressinc in forum Forms
    Replies: 8
    Last Post: 04-01-2010, 09:42 AM
  5. Replies: 0
    Last Post: 02-27-2009, 01:27 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