form multiple combo code problem

A

AJ

Can someone tell me what is wrong with this code? Or a better way??

Dim Rs As Object

Set Rs = Me.RecordsetClone
Rs.FindFirst "[Product]=""" & Me![Product] & """" And "[Strength]=""" &
Me![Strength] & """" And "[DoseForm]=""" & Me![DoseForm] & """" And
"[Distributor]""" & Me![Distributor] & """"

If Not Rs.EOF Then Me.Bookmark = Rs.Bookmark


All I want to do is filter a form by 4 fields in order to get to the one
record that needs updating via the form.

Thanks in advance.
 
D

Dirk Goldgar

AJ said:
Can someone tell me what is wrong with this code? Or a better way??

Dim Rs As Object

Set Rs = Me.RecordsetClone
Rs.FindFirst "[Product]=""" & Me![Product] & """" And "[Strength]=""" &
Me![Strength] & """" And "[DoseForm]=""" & Me![DoseForm] & """" And
"[Distributor]""" & Me![Distributor] & """"

If Not Rs.EOF Then Me.Bookmark = Rs.Bookmark


All I want to do is filter a form by 4 fields in order to get to the one
record that needs updating via the form.


I see a couple of things wrong. First, your quoting appears to be
incorrect, so that you have part of the criteria expression effectively
outside the quotes. If all your fields are in fact text fields, as your
quoting implies, then try this:

Rs.FindFirst _
"[Product]=""" & Me![Product] & _
""" And [Strength]=""" & Me![Strength] & _
""" And [DoseForm]=""" & Me![DoseForm] & _
""" And [Distributor]=""" & Me![Distributor] & """"

I also replaced a missing "=" sign in the above. If any of those fields is
not a text field, then the quoting in that expression will need to be
adjusted.

Also, in this line:
If Not Rs.EOF Then Me.Bookmark = Rs.Bookmark

.... you should *not* be testing Rs.EOF to see if you have a match or not.
Instead, test the recordset's NoMatch property:

If Not Rs.NoMatch Then Me.Bookmark = Rs.Bookmark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top