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.
snyperjAsked:
Who is Participating?
 
Rey Obrero (Capricorn1)Commented:
try this

rst.FindFirst "Customer_No = '" & Me.Customer_No & "' And Active = 'Y'"
0
 
jppintoCommented:
Please try like this:

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

jppinto
0
 
jppintoCommented:
@snyperj: we both posted at the same time with eqqual answers! Can you please explain why you only accepted one of the answers?
0
 
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:

  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.


0
 
jppintoCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.