Hi All:
I am working on a way to display results of a search. The user enters the search criteria in the form named form1. Depending upon the entry made often dictated by the location of the wild card charcter a set of different SQL statements are executed. I was wondering as to how do I transfer the results of a query to the list box in the second from 'search names'for display purposes. I have attempted to do this through the following code. When I execute this code there are no execution errors however, the code does not achieve anything. My question is as to how do I get the values displayed on the list box of the form 'searchnames.' Do I need to manipulate the record type or the record source property of the list box? Is there soemthing else that I need to do? Please, your ideas are solicited.
****strafter, strbefore and strnull are different strings storing parts of the search text depending on the location of the wild card character(e.g. strafter refers to the '*' at the end of the search text, strbefore refers to the '*' at the beginning of the search text and strnull refers to the search text if there is no wild card character)
Thanks
Info
*************************************************
If Mid(mystring, 1, 1) = "*" Then
strbefore = Mid(mystring, 2, (Len(mystring)))
strafter = vbNullString
strnull = vbNullString
strSQL = "SELECT * FROM directory WHERE last_name LIKE '" & strafter & strbefore & strnull & "%';"
'open the recordset
'rs.Open strSQL, cn, adOpenDynamic, adLockOptimistic
DoCmd.OpenForm "searchnames"
Set f = Screen.ActiveForm
'f!SelectCode.RowSource = "SELECT * FROM directory WHERE last_name LIKE '" & strbefore & strafter & strnull & "%';"
Forms!searchnames!SelectCode.RowSourceType = strSQL
Forms!searchnames!SelectCode.RowSource = "SELECT * FROM directory WHERE last_name LIKE '" & strafter & strbefore & strnull & "%';"
MsgBox (Forms!searchnames!SelectCode.RowSource & "2")
MsgBox (f!SelectCode.RowSource & "3")
,***********************
I am working on a way to display results of a search. The user enters the search criteria in the form named form1. Depending upon the entry made often dictated by the location of the wild card charcter a set of different SQL statements are executed. I was wondering as to how do I transfer the results of a query to the list box in the second from 'search names'for display purposes. I have attempted to do this through the following code. When I execute this code there are no execution errors however, the code does not achieve anything. My question is as to how do I get the values displayed on the list box of the form 'searchnames.' Do I need to manipulate the record type or the record source property of the list box? Is there soemthing else that I need to do? Please, your ideas are solicited.
****strafter, strbefore and strnull are different strings storing parts of the search text depending on the location of the wild card character(e.g. strafter refers to the '*' at the end of the search text, strbefore refers to the '*' at the beginning of the search text and strnull refers to the search text if there is no wild card character)
Thanks
Info
*************************************************
If Mid(mystring, 1, 1) = "*" Then
strbefore = Mid(mystring, 2, (Len(mystring)))
strafter = vbNullString
strnull = vbNullString
strSQL = "SELECT * FROM directory WHERE last_name LIKE '" & strafter & strbefore & strnull & "%';"
'open the recordset
'rs.Open strSQL, cn, adOpenDynamic, adLockOptimistic
DoCmd.OpenForm "searchnames"
Set f = Screen.ActiveForm
'f!SelectCode.RowSource = "SELECT * FROM directory WHERE last_name LIKE '" & strbefore & strafter & strnull & "%';"
Forms!searchnames!SelectCode.RowSourceType = strSQL
Forms!searchnames!SelectCode.RowSource = "SELECT * FROM directory WHERE last_name LIKE '" & strafter & strbefore & strnull & "%';"
MsgBox (Forms!searchnames!SelectCode.RowSource & "2")
MsgBox (f!SelectCode.RowSource & "3")
,***********************