Search Command

Liberti

Registered User.
Local time
Today, 23:41
Joined
May 28, 2002
Messages
16
I am getting the error "object required" when I click the search button.

However when i change from design view to form view the keyword that was in the textbox is searched and the correct items are displayed. Here is sample of my code. Any suggestions would be helpful.

Liberti

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

Set Me.Recordset = datordiance.Recordset

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
 

Users who are viewing this thread

Back
Top Bottom