Link to home
Start Free TrialLog in
Avatar of snyperj
snyperjFlag for United States of America

asked on

Help with opening recordsets needed



I am trying to open a recordset with two criteria items.  Customer_No in the recordset should match the Customer_No field on my form and the "Active" field in the recordset should be a "Y".   Both fields are text.

I can't seem to get the syntax for the 'active' correct.  Below is a snippet of what I am trying.

rst.FindFirst "Customer_No = '" & Me.Customer_No & "' " And "Active = '"Y"'

Where am I going wrong?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please try like this:

rst.FindFirst "Customer_No = '" & Me.Customer_No & "' And Active = 'Y'"

jppinto
@snyperj: we both posted at the same time with eqqual answers! Can you please explain why you only accepted one of the answers?

  BTW, you both beat me<g>.

  However I would have added that I don't like to use single quotes, but rather:

rst.FindFirst "Customer_No = " & Chr$(34) & Me.Customer_No  & Chr$(34) & " And Active = "  & Chr$(34) & "Y"  & Chr$(34)

  Chr$(34) is the quote character (") and to me, it's a lot easier to read this.  It also avoids the problem with names where the single quote (') may be embedded in the data.

JimD.


Jim, allow me to disagree on your point of view. If both posted the exact same answer at the exact same time, it should had been a split between both questions, not all points assign to only one of the questions. This is how I see this. But it's OK, you don't need to reopen the question or reasign the points, I'm used to this already. Sometimes we win, others we loose...

regards,

jppinto