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

Dim rs As Object runtime error 3077

Status
Not open for further replies.

bfamo

Technical User
Feb 16, 2006
132
NO
Hey you guys. Have a look at this.

I've set up a seach function in my DB. The search field in FrmSearchCustomer filters out my customers like this:
Code:
Private Sub CtrlSearch_AfterUpdate()
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[Name] = '" & Me![CtrlSearch] & "'"
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

The following passes CustomerID on to FrmCustomer:
Code:
Private Sub BtnOpenFrm_Click()

DoCmd.OpenForm "FrmCustomer", acNormal, , "[CustomerID]=Forms!FrmCusteomerSearch!CustomerID"

End Sub

Whenever a Customers name contains the character [red]'[/red], I get syntax error 3077: missing operator.

Is there any way to go around this?

thanks!
 
How about:

[tt]rs.FindFirst "[Name] = '" & Replace(Me![CtrlSearch],"'","''") & "'"[/tt]


It is best not to call fields Name, it is a reserved word.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top