Results 1 to 11 of 11
  1. #1
    tarhim47 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2010
    Posts
    57

    Angry Use of form to gather data for a query

    Hi,

    Scenario:

    I'm working on a database which holds numerous data about a number of clients.

    After the data has been entered, I want to be able to use parameters and only return information about those client which meet the parameters.

    Progress so far:

    All the data is currently in a table.

    I have made a query which has three different parameters.



    I have created an unbound form to gather data (from the user) and I have tied that form to a report. Everything works fine right now.

    Problem:

    The problem I'm having is that the form is only able to return information about clients when I use one value for a parameter.

    For example, if I want the form to return all clients which reside in ABC city, all I have to do is type in ABC in the text box in the form and the form will return all clients which reside in that city. However when I convert the city textbox to a list box which allows multiselect, the form doesnt return any data.

    Ideal solution:

    I want to make it so that I can select ABC and DEF in the form and have it return all clients which reside in ABC and DEF.

    Notes:

    I have been trying this for hours now and cant get it...maybe I'm missing something.

    Also, I'm somewhat limited using VB codes, everything Ive created so far, Ive done using Access 07 tools provided in the tabs.

    Any help is greatly appreciated and thank you in advance for all your efforts.

  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
    A multiselect listbox always has a Null value, no matter what is selected. Here's what I usually do:

    http://www.baldyweb.com/multiselect.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    tarhim47 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2010
    Posts
    57
    Hi Paul,

    Thanks for your reply.

    The example you provided is great but its difficult for me to implement. This is because the list box derives its values from a table and I cant do that. Thats because the form Ive creted will be asking for a range and not a singular value found in the table.

    For example, the table will include on date - Nov 4/10. However, the form will be asking for a starting date and an ending date. These two text boxes cant be referenced to any particular field in a table because the table has only one date.

    Any other ideas?

    Thanks!

  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
    I guess I was confused by this:

    However when I convert the city textbox to a list box which allows multiselect, the form doesnt return any data

    What is it you're selecting from the listbox?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    tarhim47 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2010
    Posts
    57
    I'm trying to select the client's city of residence. I want to be able to select multiple cities so that the form will return the information about all the clients which reside in the selected cities.

    I can use a list box for this or a combo box whichever allows me to input a list from which the user can select the desired cities.

    Does this answer your question?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It sounds like you want to be able to select multiple items from a listbox to filter a form/report, which is what that code does.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    tarhim47 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2010
    Posts
    57
    You're right! That is exactly what I''m trying to do but the code isnt working.

    How can i attach my database? I tried it yesterday and it failed to upload.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Generally if you do a compact/repair and then zip, it will upload fine.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    tarhim47 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2010
    Posts
    57
    Hey Paul,

    You can find it here...https://www.accessforums.net/forms/file-9120.html

  10. #10
    tarhim47 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2010
    Posts
    57
    Dont worry...all the data is fake.

    So the question is how I do make it so that you can select multiple cities in the conty list box and have the form return all the info about all the client within the selected cities?

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can take the parameter for county out of your query and adapt the sample VBA code in my link to open the report. To my knowledge, there's no way to get the selections from a multiselect listbox with a macro, only VBA code.
    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. Data in table but not in form or query
    By jennie999 in forum Forms
    Replies: 5
    Last Post: 10-13-2010, 09:10 AM
  2. Form not passing data to query
    By bobfin in forum Queries
    Replies: 13
    Last Post: 08-11-2010, 05:28 AM
  3. Form Data Not being passed onto query
    By fmoses in forum Queries
    Replies: 2
    Last Post: 08-20-2009, 08:33 AM
  4. Use form data in a query
    By Zholt in forum Forms
    Replies: 2
    Last Post: 05-13-2009, 07:59 PM
  5. Replies: 0
    Last Post: 11-12-2008, 05:18 PM

Tags for this Thread

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