Button that finds record based on two fields

T

td

I have a database where each record has a full file number, composed of a
ROOT file number and a SUB file number. Problem is that there are multiple
SUB file numbers for each ROOT file number. (Think of this as every person
who submits files gets a root number, and every filing that person submits
gets a chronological sub number.)

A full filing number is in the form EXYY-RRRR-SSS, where EX is always "EX",
YY is always a two digit year code, RRRR is a root filing number that is one
to four digits, and SSS is a sub filing number which is always three digits.
Once users enter the full filing number into the InputBox, I can have some
code that separates out the ROOT and SUB and assign them to different
variables as strings.

First, though, I would like to know how to apply a restriction on the form
that users enter the full file number into the InputBox, in the same way an
input mask would restrict entry into a field of a form. How do I do that?

But even if I know how to apply an input mask to an InputBox, I still need
to also know how to code a FIND statement that will look for a record that
has criteria for two different fields. In this case, those criteria would be
ROOT = "EXYY-RRR" and SUB = "SSS". How can I do that?

I appreciate any help with both or either of these problems. FYI, the code
I have so far is below, but it only searches for records that have ROOT = to
the user entry (without any input mask even)...

Private Sub FINDFILINGBTN_Click()
Dim strFindFiling As String
strFindFiling = InputBox("Enter the root file number you're looking for:")
With Me.RecordsetClone
.FindFirst "[ROOT]='" & strFindFiling & "'"
If .NoMatch Then
MsgBox "Sorry, couldn't find that filing."
Else
Me.Bookmark = .Bookmark
End If
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top