Hi,
I have a FORM linked to a single table. In many previous forms, I've been using this code described here http://www.dreamincode.net/forums/to...n-access-form/ To create a simple search text box for various numeric ID fields in tables.
This time, however, I'm wanting to do the same thing, however in this database and Table, the field [Project_Name] I'm searching for is a string.
I've been playing around with my code (based on that website) and just can't seem to get the string search to work.
Code:
Private Sub TXT_SEARCHBOX_PrjName_AfterUpdate()
If IsNull(TXT_SEARCHBOX_PrjName) = False Then
Me.Recordset.FindFirst "[Project_Name]=" & TXT_SEARCHBOX_PrjName
Me!TXT_SEARCHBOX_PrjName = Null
If Me.Recordset.NoMatch Then
MsgBox "Project Not Found", vbOKOnly + vbInformation, "Invalid Propject Name"
Me!TXT_SEARCHBOX_PrjName = Null
End If
End If
End Sub
From everything I've been reading and researching, I need to somehow put quotes around the TXT_SEARCHBOX_PrjName in the
Code:
Me.Recordset.FindFirst "[Project_Name]=" & TXT_SEARCHBOX_PrjName
shown above.
I'm not sure how to do that. I've tried the following all without success and with or without errors
Code:
Me.Recordset.FindFirst "[Project_Name]=" & "TXT_SEARCHBOX_PrjName"
Me.Recordset.FindFirst "[Project_Name]=" & 'TXT_SEARCHBOX_PrjName'
Me.Recordset.FindFirst "[Project_Name]=" & /'TXT_SEARCHBOX_PrjName/'
Me.Recordset.FindFirst "[Project_Name]="" & TXT_SEARCHBOX_PrjName"
Me.Recordset.FindFirst "[Project_Name]=" & '"TXT_SEARCHBOX_PrjName"'
Me.Recordset.FindFirst "[Project_Name]=" & "'TXT_SEARCHBOX_PrjName'"
and a few others I can't remember, but the main thing is when I use single quotes ' it tries of course to comment out the information after that, so not sure how to correctly use it if it does require single quotes.
What is the proper way to turn this search into a string search?
Secondly when that is solved, I have another field in the same table called [API_or_CC]. I would like the above search to only search for the [Project_Name] that has"API" associated with it (and not any that have 'CC')
Thanks