Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter Form based on Text Box Input 1

Status
Not open for further replies.

Mike555

Technical User
Feb 21, 2003
1,200
US
I have a table field named IDNumber that stores Social Security Numbers. I have a switchboard form with a text box and a command button.

Users are to enter a Social Security Number into the text box, and then click the command button which should open "frmAdjRequest". frmAdjRequest should then open filtered only to display records matching the user's input. It is not working. Below is my code.


Private Sub cmdSSNFilter_Click()
On Error GoTo Err_cmdSSNFilter_Click

Dim SSN As Variant
Dim FormFilter As Variant

SSN = [Forms]![FrmMainMenu]![txtSearchIDNumber]
FormFilter = "IDNumber = 'SSN'"
DoCmd.OpenForm "frmAdjRequest", , , FormFilter, , , "NoAdditions"

Exit_cmdSSNFilter_Click:
Exit Sub

Err_cmdSSNFilter_Click:
MsgBox Err.Description
Resume Exit_cmdSSNFilter_Click

End Sub

--
Mike

Why make it simple and efficient when it can be complex and wonderful?
 
Mike:

Dim stDocName as String
Dim stLinkCriteria as String

stDocname = "frmAdjRequest"
stLinkCriteria = "[IdNumber] = " & me.txtSearchIDNumber

Docmd.OpenForm stDocname,,,stLinkCriteria

HTH


"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
That works! I only needed to add some additional brackets as shown...

stLinkCriteria = "[IdNumber] = " & "'"
& Me.txtSearchIDNumber & "'"

Thanks jfgambit!

--
Mike

Why make it simple and efficient when it can be complex and wonderful?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top