Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

better search field in the form

Status
Not open for further replies.

mybers

IS-IT--Management
Mar 24, 2004
62
PH
Hello everyone!

I tried using the search keywords but its quite difficult to browse all of them that pertains to my questions. ihope anyone can guide me through it...

On my form, I have 2 fields namely: fname and Lname
Now I have an unbound text box which supposedly to find the record in the last name [lname] instead of Ctrl-F to find a record is there a better way to code the text box to find the rec?

I tried using Dlookup but the proces takes longer...Ive read about using "Seek" and maybe someone can suggest on using this one too....

thanks in advance

francis
 
Hi,
Try the following in the after update event for your unbound field.

Set rst = Me.RecordsetClone

'May need to wait for the recordset to be populated
Do While (rst.State And adStateConnecting) Or _
(rst.State And adStateFetching)
DoEvents
Loop

rst.Find "lName like '" & Me.unboundtypeboxname & "%'"

If rst.EOF Then
MsgBox ("Last Name '" & Me.unboundtypeboxname & "' is not on this screen, try again"), vbOKOnly
Me.unboundtypeboxname = Null
Me.unboundtypeboxname.SetFocus
Else
DoCmd.GoToRecord acForm, "frmnameyouhaveopen", acGoTo, rst.Bookmark
Me.fieldyouwanttopointto.SetFocus
End If
rst.Close
Set rst = Nothing
End Sub

Post back if you are confused.
Good luck



Remember when... everything worked and there was a reason for it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top