
Signature
Don''t forget to rate the post if it was helpful!
email address is invalid
Please reply to newsgroup only.
Good, Dale, but one problem.
You don't want to use the Change event. It means what it says. It fires
everytime you make any change to the value of the control which means it will
fire after every keystroke. It really should be the After Update event and
the test to change it should be after you do the find. Actually, now that I
think about it, I would do it all in the Click event event:
Private sub cmd_Find_Click
Dim strCriteria As String
strCriteria = "[Last_Name] Like ""*" & me.txt_Find & "*"""
With Me.RecordsetClone
If Me.cmd_Find.Caption = "&Find" Then
me.cmd_Find.Caption = "&Find Next"
.findfirst strCriteria
If .NoMatch Then
Msgbox "Could not find a last name similar to '" & me.txt_Find
Else
Me.Bookmark = .Bookmark
Me.cmd_Find.Caption = "&Find Next"
End If
Else
.FindNext strCriteria
If .NoMatch Then
Msgbox "No More Last Names Matching '" & me.txt_Find
Me.cmd_Find.Caption = "&Find"
End If
End If
End Sub
And, to keep the Find/FindNext displaying correctly, put
Me.cmd_Find.Caption = "&Find"
in the form Current event and in the Got Focus event of txt_Find

Signature
Dave Hargis, Microsoft Access MVP
> The easiest way would probably be to start out with code in the Change event
> of txt_Find, something like:
[quoted text clipped - 72 lines]
> > > > while I want it to look for any part of it. ie: I want to find a customer but
> > > > am unsure as to how it is entered exactly in the form.
JennKriv - 18 Apr 2008 19:37 GMT
I got a compile error comming up at the Me.txt_Find with the .txt_find
highlighted I can't figure out what it needs to be changed to.
> Good, Dale, but one problem.
> You don't want to use the Change event. It means what it says. It fires
[quoted text clipped - 107 lines]
> > > > > while I want it to look for any part of it. ie: I want to find a customer but
> > > > > am unsure as to how it is entered exactly in the form.
Klatuu - 18 Apr 2008 19:42 GMT
Do you have a control on your form named txt_Find? It should be the name of
the text box control you want to do the search on.
When asking about an error, it helps to point out the line and include the
error number or message.

Signature
Dave Hargis, Microsoft Access MVP
> I got a compile error comming up at the Me.txt_Find with the .txt_find
> highlighted I can't figure out what it needs to be changed to.
[quoted text clipped - 110 lines]
> > > > > > while I want it to look for any part of it. ie: I want to find a customer but
> > > > > > am unsure as to how it is entered exactly in the form.
JennKriv - 18 Apr 2008 19:41 GMT
I also want to look up a number on a different form. I think this may be why
I got the compile error. how do I change that to look for a number value?
> Good, Dale, but one problem.
> You don't want to use the Change event. It means what it says. It fires
[quoted text clipped - 107 lines]
> > > > > while I want it to look for any part of it. ie: I want to find a customer but
> > > > > am unsure as to how it is entered exactly in the form.
Klatuu - 18 Apr 2008 20:16 GMT
You would need to duplicate the code in the other form. To use a number, you
need to change the syntax a bit
Private sub cmd_Find_Click
Dim strCriteria As String
strCriteria = "[Number Field] = " & me.txt_Find
With Me.RecordsetClone
If Me.cmd_Find.Caption = "&Find" Then
me.cmd_Find.Caption = "&Find Next"
.findfirst strCriteria
If .NoMatch Then
Msgbox "Could not find a last name similar to '" & me.txt_Find
Else
Me.Bookmark = .Bookmark
Me.cmd_Find.Caption = "&Find Next"
End If
Else
.FindNext strCriteria
If .NoMatch Then
Msgbox "No More Last Names Matching '" & me.txt_Find
Me.cmd_Find.Caption = "&Find"
End If
End If
End Sub

Signature
Dave Hargis, Microsoft Access MVP
> I also want to look up a number on a different form. I think this may be why
> I got the compile error. how do I change that to look for a number value?
[quoted text clipped - 110 lines]
> > > > > > while I want it to look for any part of it. ie: I want to find a customer but
> > > > > > am unsure as to how it is entered exactly in the form.
Dale Fye - 18 Apr 2008 20:09 GMT
Dave,
Actually, I like the idea of changing it back to '&Find' in the GotFocus
event of txt_Find; that makes more sense than the Change event. But if you
do that in the forms Current event as well, won't that change it back to
'&Find' every time you find a match? In which case, you would never get a
'&FindNext', would you?

Signature
Don''t forget to rate the post if it was helpful!
email address is invalid
Please reply to newsgroup only.
> Good, Dale, but one problem.
> You don't want to use the Change event. It means what it says. It fires
[quoted text clipped - 107 lines]
> > > > > while I want it to look for any part of it. ie: I want to find a customer but
> > > > > am unsure as to how it is entered exactly in the form.
Klatuu - 18 Apr 2008 20:13 GMT
You are correct. I forgot it is changing records. It should only do it in
the text box Got Focus event.
Good catch

Signature
Dave Hargis, Microsoft Access MVP
> Dave,
>
[quoted text clipped - 115 lines]
> > > > > > while I want it to look for any part of it. ie: I want to find a customer but
> > > > > > am unsure as to how it is entered exactly in the form.