Results 1 to 14 of 14
  1. #1
    SeaTigr is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Location
    U.S.A.
    Posts
    38

    Option Group Query

    Greetings all.



    For my latest conundrum, I am trying to construct a query that utilizes an option group selection for its criteria.

    So, on a form for entering new equipment into the inventory database, a user utilizes the option group to indicate who owns the piece of equipment.

    When the query executes, the column governed by the option group simply returns a number, which I assume to be the ID key for the option selected. I would like to have it return the plain text name of the division associated with that number.

    How do I do this?


    Many thanks in advance.

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    In the underlying table, do you have the division field set up as a lookup field?

  3. #3
    SeaTigr is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Location
    U.S.A.
    Posts
    38
    It's set up as text.

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Text is the datatype or field size, but do you have it set up as a lookup field in your table? To find out: open the table in design view, click on the field name, then go to the lower pane and click on the Lookup tab. If the display control property is set to anything other than text box, you have a lookup field.

    How are you running the query from your form?
    Can you provide a little more detail on your table structure (table names, field names and relationships)?

  5. #5
    SeaTigr is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Nov 2011
    Location
    U.S.A.
    Posts
    38
    The display control property for the field is set to "Text Box".

    On the query form I recreated the option group from the "new equipment" form. The order of the options is identical. What I've done for my other queries is to create the queries, put in the various fields I want returned, and set the criteria for the field being queried to look for input from the form. For example: [Forms]![Queries & Reports]![TxtSerial#]

    TxtSerial# is a text box on the Queries & Reports form that allows a user to enter the serial number of the equipment they are looking for. I have a command button created that the user clicks after entering the serial number, which is linked to the serial number query. I have a separate command button for every query (system name, equipment type, brand name, etc.).

    The basic structure is I have an Equipment Table that has records added to it from the Equipment Form. The Equipment Form has multiple fields for entering pieces of information (system name, equipment type, brand name, model, operating system, amperage, etc.). There are combo boxes for fields I didn't want users typing in every possible spelling under the sun. The options for a combo box are drawn from another table (with each combo box having its own associated table to draw options from). So, for example, the system name field is a combo box. There is a System Name List, a table where I entered all the system names. The combo box references that table when providing options for the user to choose from.

    In my Relationships I have linked each list to its corresponding field in the Equipment Table.

  6. #6
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Everything you describe seems OK.

    Going back to your initial post:
    When the query executes, the column governed by the option group simply returns a number, which I assume to be the ID key for the option selected. I would like to have it return the plain text name of the division associated with that number.
    Did you verify that the number returned is indeed the ID key of the table? Can you post the SQL text of that query?

  7. #7
    SeaTigr is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Nov 2011
    Location
    U.S.A.
    Posts
    38
    The option group is not associated with any table other than the Equipment Table. I created the option group on the Equipment Form, noted the options in the wizard, and chose the check mark style for the option group.


    Here's the query as I've structured it.Click image for larger version. 

Name:	EquipmentQuery.jpg 
Views:	17 
Size:	65.9 KB 
ID:	7332

    Since this is a public forum, I blanked out any potentially identifying information. The criteria for the equipment ownership, OG_EquipmentOwner, means Option Group_Equipment Owner. This query does execute properly when using the option group on the Queries & Reports Form. It just returns the number instead of the plain text. I'm not sure if the plain text is recorded anywhere except the label/text box/whatever next to the check boxes in the option group.

  8. #8
    SeaTigr is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Nov 2011
    Location
    U.S.A.
    Posts
    38
    Here's the SQL:

    SELECT [$$$ Systems List].System, [Unit Type List].[Computer Type], [$$$ Equipment Table].[Unit Brand], [$$$ Equipment Table].[Unit Model], [Operating Systems List].[Operating System], [$$$ Equipment Table].[Unit Serial #], [$$$ Equipment Table].[Unit $$$ #], [$$$ Equipment Table].[Service Tag #], [$$$ Equipment Table].[$$$ Equipment], [$$$ Equipment Table].[$$$ Number]
    FROM [Unit Type List] INNER JOIN ([$$$ Systems List] INNER JOIN ([Operating Systems List] INNER JOIN [$$$ Equipment Table] ON [Operating Systems List].ID = [$$$ Equipment Table].[Unit OS]) ON [$$$ Systems List].ID = [$$$ Equipment Table].[System Name]) ON [Unit Type List].ID = [$$$ Equipment Table].[Unit Type]
    WHERE ((([$$$ Equipment Table].[$$$ Equipment])=[Forms]![Queries & Reports]![OG_EquipmentOwner]));


    "$$$" Represents where I've removed identifying information.

  9. #9
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    I created the option group on the Equipment Form, noted the options in the wizard, and chose the check mark style for the option group.
    I am guessing that it is pulling the numbers you assigned when creating the option group which will not work to do the filtering correctly.

    Out of curiosity are the system name, unit type and unit OS fields in your equipment table text field or number fields?

    Similarly, what is the datatype of the 3 ID fields in the related tables?

  10. #10
    SeaTigr is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Nov 2011
    Location
    U.S.A.
    Posts
    38
    The system name, unit type, and unit OS fields in the equipment table are number fields. The ID fields in the related tables are AutoNumber. I got the plain text of those to display properly by having the queries display the text field from the related tables.

  11. #11
    SeaTigr is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Nov 2011
    Location
    U.S.A.
    Posts
    38
    Hmmmm...so it sounds like I can't set up a query to return text instead of a number. I suppose the solution is to create a separate list with the divisions and make it a combo box field instead of an option group.

  12. #12
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You are correct, you should be using combo boxes based on the respective related tables. The bound field of the combo box should be the ID, you would set the column width of the ID column to 0 and the text name to something other than zero (then that is what the user will see). I recommend using the combo box wizard to set up the combo boxes.

  13. #13
    SeaTigr is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Nov 2011
    Location
    U.S.A.
    Posts
    38
    Thank you for your patient help on this matter.

  14. #14
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome.

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

Similar Threads

  1. Option Group
    By x__hoE__x in forum Access
    Replies: 2
    Last Post: 12-10-2011, 09:39 AM
  2. Option Group on a Report
    By Paul H in forum Reports
    Replies: 1
    Last Post: 10-21-2011, 01:09 PM
  3. Option Group - Borders are gone
    By cevatyildiz in forum Forms
    Replies: 0
    Last Post: 04-30-2010, 06:08 AM
  4. Option Group
    By huskies in forum Forms
    Replies: 9
    Last Post: 12-02-2009, 12:06 PM
  5. Option Group broken out
    By dcecil in forum Reports
    Replies: 3
    Last Post: 04-21-2009, 10:30 AM

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