How to open a form based on data entered into INPUTBOX, unless there are more than one matching records

Hello Experts,
I have records with the following type of Primary Key...   YYYY-MM-11111.  
(Year record was created, month created, sequential 5 digit # counting from the 1st of each year)  
Relatively new database, currently they are up to "2015-02-00841"  

I'd like to tie some code to a command button that asks for the last 5 digits, and opens a form with the matching record.   The challenge comes in that if there are more than one records that have those last 5 digits, it would need to bring up a list of the matching records... the user could then select a record from that list to open the form.

The above is the basic need....
What would be awesome is that if it did find more than one record that matched the last 5 digits BUT all but one were more than XX days old, it would not present the list, but go ahead and open the form with the most recent record.

Any help would be appreciated.
TechGuiseAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PatHartmanCommented:
A simple way is to use a combo.  Create a query that selects the ID's as field 1 and then the last 5 digits as field 2 suffixed by the YYYY-MM instead of prefixed by it.  Order the query by field 2.  Use this query as the rowsource for the combo.  Hide field1, show field 2.  If you add the combo to a bound form using the wizard, one of the options will be to find a record on the current form, choose that one.
0
Rey Obrero (Capricorn1)Commented:
try this as you requested

Private Sub Command0_Click()
Dim strFind As String, strPrefix As String, strNum As String
strPrefix = Year(Now())
strNum = InputBox("Enter: Number 00000")
Stop
If strNum & "" <> "" Then
    strFind = strPrefix & "-**-" & strNum
    Debug.Print strFind
    DoCmd.OpenForm "Form1", , , "[PKName] Like '" & strFind & "'"
End If
End Sub
0
Rey Obrero (Capricorn1)Commented:
try this as you requested

 Private Sub Command0_Click()
 Dim strFind As String, strPrefix As String, strNum As String
 strPrefix = Year(Now())
 strNum = InputBox("Enter: Number 00000")

 If strNum & "" <> "" Then
     strFind = strPrefix & "-**-" & strNum
     Debug.Print strFind
     DoCmd.OpenForm "Form1", , , "[PKName] Like '" & strFind & "'"
 End If
 End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.