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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Goto a record in a subform Based on a changing value in the parent.

Status
Not open for further replies.

Bretto

Technical User
Oct 17, 2001
59
AU
I almost have this working; I have a form with a text box (txtcusfnd) in the parent form and a subform with a Datasheet table (SF_CusFnd). As you type the customer name in txtCusFnd it bookmarks the record in the SF_CusFnd with the closest value to txtCusFnd moving to a closer value with each letter you type.

HERE IS THE CODE I HAVE USED SO FAR:

Private Sub txtCusFnd_Change()
' Find the record that closest matches the control as you type.

Dim strCusFnd As String

strCusFnd = Me.txtCusFnd.Text
strCusFnd = strCusFnd & "*"

Forms!f_cusFnd.SF_CusFnd.Form.RecordsetClone.FindFirst _
"[CusNam] like '" & strCusFnd & "'"

Forms!f_cusFnd.SF_CusFnd.Form.Bookmark = _
Forms!f_cusFnd.SF_CusFnd.Form.RecordsetClone.Bookmark


End Sub

THE PROBLEM IS:

If you type an apostrophe (') it will create an invalid string error!. Can I get around this somehow by replacing the apostrophe (') with a star (*) in the code? If so how do I do it? Or if there are any other ways around this problem it would be cool to know.

Your help will be appreciated.

Cheer's
Bretto.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top