Results 1 to 9 of 9
  1. #1
    rbhazie is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    3

    Existing Access Database lookup

    So I have an existing database that we use to input our computer cables that we install and number.
    I want to make a form or something that I can use to extract a group of numbers.
    Ex: I need a cable report for numbers 5000 to 5020 and all of the info that goes with numbers.
    I want to make something that I can just key in the numbers that I need and then have access spit out the report.


    Is there an easy way to do this?

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    You could try a parameter query and if successful, make a form based on it. However, I don't know if a parameter query will accept multiple inputs (e.g. IN([input 1], [Input 2],...) and even if it does, it may not produce any results if one parameter is dismissed.

    When multiple inputs are involved, it's common to loop through the selected items property of multi select listbox and build sql in code from that, then base the records on the sql statement by setting a form recordsource to that sql.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    We don't know the design of your table(s). So if you could post your table design(s) and any relationships you have, it would help readers. I agree with micron re multi select listbox, but we really need to know little more about the database.
    Yes a parameter query can take multiple parameters.

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Multiple parameters using IN clause? Usually it's done as 1 per field but I don't think I have ever tried several in 1 field using IN.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    My response was with respect to multiple parameters generally--Not specific to the IN operator.

    However:

    These parameter queries work in my testing.

    1:
    Code:
    PARAMETERS P1 Text ( 255 ), P2 Text ( 255 );
    SELECT animal.[AName], *
    FROM animal
    WHERE Left(animal.[AName],1 ) In ([P1],[P2]);
    2:
    Code:
    PARAMETERS P1 Text ( 255 ), P2 Text ( 255 );
    SELECT animal.[AName], *
    FROM animal
    WHERE (((animal.[AName]) In ([P1],[P2])));
    Result of 1: with the attached table, using P1 = J, P2 = S

    AName AnimalId
    Spot 1
    Jim 2
    Sam 3
    Johnny 7
    Attached Thumbnails Attached Thumbnails ParmWithIN.PNG  

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    you can also try this variation

    Code:
    PARAMETERS Enternumbers Text ( 255 )
    SELECT *
    FROM tblCables
    WHERE Eval(cableNum & " In (" & [Enternumbers] & ")")
    for enternumbers you would enter numbers separated by a comma

    5000,5001,5002

    but you do say

    need a cable report for numbers 5000 to 5020
    in which case rather than typing 100 characters your query would be

    Code:
    PARAMETERS FromNum Long, ToNum Long;
    SELECT *
    FROM tblCables
    WHERE cableNum BETWEEN FromNum and ToNum
    and you have only entered 8 characters

    and as you can see has very different parameters and criteria

    you might want to consider using vba and build your criteria in code so you could enter something like

    5000,5003,5010-5020

    i.e split the string on commas then split each element on -and treat accordingly

  7. #7
    rbhazie is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    3
    I have been trying to post a pic of my Cable Form to input date. What I would like to do if possible
    is to have a "Form" that I can input the umbers I need to report on and then have the report in excel

  8. #8
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    you have had some suggestions - why don't they work for you?

    regards a picture of the form, upload by all means but of more relevance would be the tables and relationships - and try zipping your file/s and upload the zip

  9. #9
    rbhazie is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    3
    I am not that fluent in access. The suggestions are great, I just don't know how to implement them.

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

Similar Threads

  1. Replies: 5
    Last Post: 06-27-2017, 07:57 AM
  2. Replies: 2
    Last Post: 04-27-2016, 06:20 AM
  3. Replies: 7
    Last Post: 03-22-2015, 02:29 AM
  4. Moving an existing Access Database backend into a SQL Server?
    By IncidentalProgrammer in forum SQL Server
    Replies: 9
    Last Post: 09-16-2014, 08:13 AM
  5. Link Existing Access Database to Outlook Contacts
    By rdaled in forum Database Design
    Replies: 3
    Last Post: 12-17-2009, 10:21 AM

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