Results 1 to 4 of 4
  1. #1
    wjm821 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2021
    Posts
    6

    Qry from a Table

    How to you get to the bottom of the table. Example with a form [Forms]![MainForm]![MainName.cmbobox(1).
    My table tblProduct has ProductID, ProductName,ProductCost. Under ProductName there's a list P1, P2,P3,P4. In my qry I need to pull P1. Im stuck. Code I have [tblProduct]![ProductName]! ((( how to get P1)))). Thank you

  2. #2
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    It's still not clear to me what you are really after... But the SQL code below should be a direct answer to your example question.
    Code:
    SELECT ProductID, ProductName, ProductCost FROM tblProduct WHERE ProductName = "P1";
    Here is a query that will grab all the records and sort them
    Code:
    SELECT ProductID, ProductName, ProductCost FROM tblProduct ORDER BY ProductName ASC;
    To sort in reverse order use DESC instead of ASC. In fact the ASC is optional, sorting is assumed to be ascending by default.

    But I assume you are using a form, in that case it's better to leave the sorting to the form by using the Order By property of the form.

    If you are trying to open a form to a specific record you would use DoCmd.OpenForm
    Code:
    DoCmd.OpenForm "FORM_NAME_HERE", , , "SEARCH_CRITERIA_HERE"
    Making assumptions from the code you've posted above that would look maybe something like this
    Code:
    DoCmd.OpenForm "FORM_NAME_HERE", , , "ProductName = '" & Me.cmbobox & "'"
    Finally, if it is that you are trying to reference a combobox on a form from a query then it might look like this:
    Code:
    SELECT ProductID, ProductName, ProductCost FROM tblProduct WHERE ProductName = [Forms]![MainForm]![cmbobox];

  3. #3
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,563
    Hi

    These fields in a table P1, P2,P3,P4 are known as Repeating Groups.

    They should be Records in a Related Table

    Can you upload a zipped copy of your Db?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Quote Originally Posted by mike60smart View Post
    Hi

    These fields in a table P1, P2,P3,P4 are known as Repeating Groups.

    They should be Records in a Related Table

    Can you upload a zipped copy of your Db?
    Those are records/values in ProductName field?
    Under ProductName there's a list P1, P2,P3,P4
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 3
    Last Post: 03-31-2021, 10:31 AM
  2. Replies: 1
    Last Post: 07-07-2017, 01:10 AM
  3. Replies: 4
    Last Post: 08-30-2012, 07:58 PM
  4. Replies: 8
    Last Post: 03-22-2012, 08:48 AM
  5. Replies: 2
    Last Post: 10-27-2009, 07:09 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