Search for record which needs two search terms

  • Thread starter Thread starter anthony
  • Start date Start date
A

anthony

I have a table where the records are uniquely identified by a
combination of two fields ChildAOLTermID and PhotoID. I want to use a
combo on a form to look up records in the table. In the AfterUpdate
event:

DoCmd.SearchForRecord , , acFirst, "[ChildAOLTermID] = " &
Me.cboFindRecord.Column(0)

works but doesn't get me to the precise record I need because the
PhotoID side of the record is not being specified. However, if I add
that so that the search looks like:

DoCmd.SearchForRecord , , acFirst, "[ChildAOLTermID] = " &
Me.cboFindRecord.Column(0) And "[PhotoID] = " &
Me.cboFindRecord.Column(1)

then I get type mismatch. Now, either of those two criteria will work
on their own but not when put together so it's their combination that
gives the error not any problem with the data type

How do I smoke this one?

Many thanks
 
Hi Anthony, are both IDs actually numbers?

The datatype mismatch makes me suspect that one of them is text. You need
more quote marks if they are. Besides, your quote mark for the second bit of
the criteria is in the wrong place - it should come 1 space before the And.

Good explanations for criteria with strings is here

http://allenbrowne.com/casu-07.html

and
 
Back
Top