+ Reply to Thread
Results 1 to 11 of 11

Access 2010 criteria to seek last 4 digits of 6 digit number

  1. #1
    Forum Contributor
    Join Date
    03-22-2012
    Location
    Narragansett, Rhode Island
    MS-Off Ver
    Excel 2007
    Posts
    122

    Access 2010 criteria to seek last 4 digits of 6 digit number

    Hi

    I am working with the Medicare Provider Number. The number always consists of 6 digits. The first two identify the State in which the provider is located. The last 4 digits signify the type of facility. Critical Access Providers, for example, all have a number with the last 4 digits ranging from 1300-1399. My question is can I add a criterion to an Access 2010 query that scans the provider numbers ranging from 000001-759999 and returns only those providers with the last four digits ranging from 1300-1399?

    Thank you for taking the time to read/consider this request.

    Al Charbonneau

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Access 2010 criteria to seek last 4 digits of 6 digit number

    Al Charbonneau,

    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Contributor
    Join Date
    03-22-2012
    Location
    Narragansett, Rhode Island
    MS-Off Ver
    Excel 2007
    Posts
    122

    Re: Access 2010 criteria to seek last 4 digits of 6 digit number

    Hi

    Thank you for responding to my query. Unfortunately, I couldn't get it to work. After entering the statement in the PRVDR_NUM column, I got the following message" check subquery's syntax and enclose the subquery in parentheses." It is very possible that I did not (1) adequately describe what I am working with and (2) did not put the correct table names in that statement. Here is what I did:

    Please Login or Register  to view this content.
    I am working with two linked files: Hosp_2010_RPTa and Hosp_2010_NMRCa. The value common to both is the record number. The provider number (PRVDR_NUM) resides in the Hosp_2010_RPTa file.

    Hope this helps you to help me.

    Thanks again for your help.

    Al Charbonneau
    Last edited by jeffreybrown; 10-10-2012 at 10:33 PM.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,888

    Re: Access 2010 criteria to seek last 4 digits of 6 digit number

    What happens when you run the query. Do you get an error message? Erroneous data? No data? Help us to help you by giving us some information.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Contributor
    Join Date
    03-22-2012
    Location
    Narragansett, Rhode Island
    MS-Off Ver
    Excel 2007
    Posts
    122

    Re: Access 2010 criteria to seek last 4 digits of 6 digit number

    Thanks for responding.

    I got the following error message "check subquery's syntax and enclose the subquery in parentheses" which did not allow me to run the query.

    Thanks

    Al

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,888

    Re: Access 2010 criteria to seek last 4 digits of 6 digit number

    Al
    Is this your total query, because the error message says you have a subquery, but I don't see one here
    "SELECT [Hosp_2010_RPTa].[PRVDR_NUM]
    FROM [Hosp_2010_RPTa]
    WHERE Right([Hosp_2010_RPTa].[PRVDR_NUM],4) Between 1300 And 1399;"

  7. #7
    Forum Contributor
    Join Date
    03-22-2012
    Location
    Narragansett, Rhode Island
    MS-Off Ver
    Excel 2007
    Posts
    122

    Re: Access 2010 criteria to seek last 4 digits of 6 digit number

    Yes. That is the total guery. Tigeravatar recommended it in the following generic form.

    SELECT [Table Name].[Provider Number]
    FROM [Table Name]
    WHERE Right([Table Name].[Provider Number],4) Between 1300 And 1399;

    I filled in the tables guessing what needs to be in place. My original question was posted at 4:50 PM today followed by Tigeravatar's recommendation at 5:37 PM.

    Thanks for your interest.

    Al

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Access 2010 criteria to seek last 4 digits of 6 digit number

    Quote Originally Posted by alcharbonneau View Post
    Hi

    After entering the statement in the PRVDR_NUM column
    That isn't where the query goes.

    Try this.

    1 Create a new query

    2 Open it's SQL view.

    3 Paste the query, with your changes, tigeravatar posted

    4 Run the query.

  9. #9
    Forum Contributor
    Join Date
    03-22-2012
    Location
    Narragansett, Rhode Island
    MS-Off Ver
    Excel 2007
    Posts
    122

    Re: Access 2010 criteria to seek last 4 digits of 6 digit number

    Hi

    Thanks for responding. Frankly, I don't like to leave things hanging but I don't know enough about Access to contribute much to solving my problem. I tried the copy and paste into the SQL view in a new query. I got an error message: characters found at the end of the SQL statement. Then I began to realize that I had not explained that I am trying to edit the data extracted from two linked files so I though I would paste the SQL statement for a query that I have (1) used to successfully data and (2) would like to edit.

    SELECT Hosp_2010_NMRCa.RPT_REC_NUM,
    Hosp_2010_RPTa.PRVDR_NUM,
    Hosp_2010_NMRCa.WKSHT_CD,
    Hosp_2010_NMRCa.LINE_NUM,
    Hosp_2010_NMRCa.CLMN_NUM,
    Hosp_2010_NMRCa.ITM_VAL_NUM,
    Hosp_2010_RPTa.FY_BGN_DT,
    Hosp_2010_RPTa.FY_END_DT
    FROM Hosp_2010_RPTa INNER JOIN Hosp_2010_NMRCa ON Hosp_2010_RPTa.RPT_REC_NUM = Hosp_2010_NMRCa.RPT_REC_NUM
    WHERE (((Hosp_2010_NMRCa.WKSHT_CD)="S200000") AND ((Hosp_2010_NMRCa.LINE_NUM)="01900") AND ((Hosp_2010_NMRCa.CLMN_NUM)="0100"));

    This query returns the requested information for 3000+ hospitals with 6 digit provider numbers ranging from 000001 - 759999. I would like the query to retrieve the data for hospitals with provider numbers that have 1300-1399 as the last 4 digits (from the right).

    Thanks for taking the time to weigh in on this solution.

    I hope this helps to clarify my problem.

    Al Charbonneau

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Access 2010 criteria to seek last 4 digits of 6 digit number

    Is that query returning all hospitals?

    Does it do what you want if you change the WHERE clause to this.

    WHERE (((Hosp_2010_NMRCa.WKSHT_CD)="S200000")
    AND ((Hosp_2010_NMRCa.LINE_NUM)="01900")
    AND ((Hosp_2010_NMRCa.CLMN_NUM)="0100"))
    AND Right([Hosp_2010_RPTa].[PRVDR_NUM],4) Between 1300 And 1399;

  11. #11
    Forum Contributor
    Join Date
    03-22-2012
    Location
    Narragansett, Rhode Island
    MS-Off Ver
    Excel 2007
    Posts
    122

    Re: Access 2010 criteria to seek last 4 digits of 6 digit number

    Bingo. Worked perfectly.

    Thank you very much.

    Al

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1