Keyword Search to Listbox

Liberti

Registered User.
Local time
Today, 21:41
Joined
May 28, 2002
Messages
16
I am doing my first Internship and I have built a database of city ordinances. I have created a form that allows my users to enter a keyword to search by. I have this connected to a query but upon opening the form the keyword is asked, I would like the user to be in the form when they enter the keyword.
Then I would like to know how you clear the form, and once the listbox is full of ordinances to be able to double click the ordinance and all the information is placed in a text box also on the form.
 
Here is some of my code.Private Sub cmdSearch_Click()
On Error GoTo Err_cmdSearch_Click

Const AposAst As String = "'*", AstApos As String = "*'"
Dim Target As String

Forms!frmordinanceinfo!Txtkeyword.SetFocus
If Txtkeyword.Text <> "" Then
'Do Nothing

Else
Txtkeyword.Text = "*"
End If

If Txtkeyword.Text = " " Then
MsgBox "You must Enter a Keyword to Search."
Txtkeyword.SetFocus
Else
Target = "Description/Title like " & AposAst & Txtkeyword & AstApos
datordinance.Recordset.FindFirst Target 'Look for first Match
If datordinance.Recordset.nomatch Then 'No Matches
MsgBox "No Matching Ordinance."
Txtkeyword.Text = " "
Txtkeyword.SetFocus
Else
Do Until datordinance.Recordset.nomatch
datordinance.Recordset ("Description/Title")
datordinance.Recordset.FindNext Target
Loop
End If
End If

Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_cmdSearch_Click:
Exit Sub

Err_cmdSearch_Click:
MsgBox Err.Description
Resume Exit_cmdSearch_Click

End Sub

Thank you for your suggestions.
 

Users who are viewing this thread

Back
Top Bottom