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

Finding A Record

Status
Not open for further replies.

zp162002

Programmer
Feb 3, 2003
39
US
Hello All,

I'm trying to find a record in a table based upon two fields from a form using the code below.

rs.FindFirst "[SellerNameID] = '" & strSellerName & "' And [AuctionNum] = '" & strAuctionNum & "'"

Each time this line of code executes, I receive an error message stating:
"Run-time error '3077':

Syntax error (missing operator) in expression."

Any ideas on what I'm leaving out? Thanks.

Patrick
 
if AuctionNum is indeed a number then there is no need to surround it with quotes
 
AuctionNum is a text field. It can contain either text or numbers.

Is there a more efficient way to code this?
 
And this ?
rs.FindFirst "SellerNameID=[tt]'"[/tt] & Replace(strSellerName, [tt]"'", "''") & "'[/tt] AND AuctionNum=[tt]'"[/tt] & Replace(strAuctionNum, [tt]"'", "''") & "'"[/tt]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
That's what my problem is - I have apostrophes in the string. I'm using Access 97 (I know - my company is way behind the times) and it doesn't recognize Replace. Isn't there a way to replace the apostrophes using some Ascii code?
 
could or use your own replace function

Code:
Public Function SReplace(strOrig As String, Optional StrOld As String, Optional StrNew As String) As String
'performs something like excel replace function
Dim i As Integer
SReplace = ""
i = 1
While i <= Len(strOrig)
    SReplace = SReplace & IIf(Mid(strOrig, i, 1) = StrOld, StrNew, Mid(strOrig, i, 1))
    i = i + 1
Wend
End Function

here is a sub. place it in a module then use SReplace
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top