T
Tony Scullion
Hi Group,
I have built an advanced search form and need help with
the following.
My search form allows an user to select a field from
combo 'cbxFld', select an operator from
combo 'cboOperator' and to enter text using a text box
called 'txtVal'. I wrote some VB code to 'join' this
search together to make a Where statement, which is used
to filter records on a subform.
It works fine when I perform searches using numbers but
when I try to perform a search using a text entry it
throws up 2 grey paramater boxes asking for info!? I know
the problem is a parenthesis problem but after hours of
trying I can't work it out. Can someone help me to get
the SQL to work all searches (text, numbers & like etc)?
Manu thanks for your expertise
Tony
PS here is the VB code used to build the SQL
strTable = "Part"
strSQL = "SELECT Part.ProductID, Part.PartID,
Part.PartName, Part.Price, Part.Date "
If Not IsNull(Me("txtVal" & i)) Then 'Peform
search if textbox is not blank
strWhere = strWhere & strJoinType & "[" & Me
("cbxFld" & i) & "]" & Me("cboOperator" & i) & Me("txtVal"
& i)
Else
strWhere = " FROM " & strTable & ""
End If
strSQL = strSQL & " FROM " & strTable & " Where " &
strWhere
'*** change the recordsource of the subform
Me.PartSubformNew.Form.RecordSource = strSQL
Me.PartSubformNew.Form.Requery
I have built an advanced search form and need help with
the following.
My search form allows an user to select a field from
combo 'cbxFld', select an operator from
combo 'cboOperator' and to enter text using a text box
called 'txtVal'. I wrote some VB code to 'join' this
search together to make a Where statement, which is used
to filter records on a subform.
It works fine when I perform searches using numbers but
when I try to perform a search using a text entry it
throws up 2 grey paramater boxes asking for info!? I know
the problem is a parenthesis problem but after hours of
trying I can't work it out. Can someone help me to get
the SQL to work all searches (text, numbers & like etc)?
Manu thanks for your expertise
Tony
PS here is the VB code used to build the SQL
strTable = "Part"
strSQL = "SELECT Part.ProductID, Part.PartID,
Part.PartName, Part.Price, Part.Date "
If Not IsNull(Me("txtVal" & i)) Then 'Peform
search if textbox is not blank
strWhere = strWhere & strJoinType & "[" & Me
("cbxFld" & i) & "]" & Me("cboOperator" & i) & Me("txtVal"
& i)
Else
strWhere = " FROM " & strTable & ""
End If
strSQL = strSQL & " FROM " & strTable & " Where " &
strWhere
'*** change the recordsource of the subform
Me.PartSubformNew.Form.RecordSource = strSQL
Me.PartSubformNew.Form.Requery