need help grabbing text from a form into a query

  • Thread starter Thread starter Caldie
  • Start date Start date
C

Caldie

Guest
basic problem (i hope)
i am building a search function for a database, I am trying to use a text box on a form to set the search text, which then opens then result in a subform. I can get this working when i open the results as a regular form, like so
stLinkCriteria = "[Name]" & "LIKE" & "'" & "*" & Me![SearchText] & "*" & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

but when i open it as a subform like this:
ChildFrm.SourceObject = "FrmAlbumSearch"

i cant work out how to apply the filter to show only the fields that match the search text..

I am trying to get around this by using a query for the subform, but i cant work out how to grab whatever is in the searchtext text box on the main form, and insert it in the query to give me the right results..

a solution to either problem would be greatly appreciated, thanks for the help
 
Try this type of code

Please try code like this...it is really working ...giv eme your commenets...

Private Sub CmdSearch_Click()
On Error GoTo Err_CmdSearch_Click

Dim vSearchString, x As String
'vSearchString = "[Consultant Table]." & Me.Combo0.Column(1)
vSearchString = Me.Combo0.Column(1)
Dim abc As String
abc = "SELECT [Consultant Table].Consultant_ID AS [ConsID],"
abc = abc & "[Consultant Table].Surname,"
abc = abc & "[Consultant Table].First_Name,"
abc = abc & "[Nationality Table].Nationality,"
abc = abc & "[Consultant Table].Process_Status"
abc = abc & " FROM ([Consultant Table] INNER JOIN [Nationality Table] ON [Consultant Table].[Nationality] = [Nationality Table].[Nationality_ID]) WHERE (((" & vSearchString
abc = abc & ") Like ""*" & Me.Text2 & "*"" )) ORDER BY [Consultant_ID];"
Me.List11.RowSource = abc
Me.List11.Requery

Exit_CmdSearch_Click:
Exit Sub

Err_CmdSearch_Click:
MsgBox Err.Description
Resume Exit_CmdSearch_Click

End Sub
 

Users who are viewing this thread

Back
Top Bottom