findfirst with multiple columns

J

JHC

I have a table keyed by 3 elements (Schema_Name, Table_Name and
DataElement_Name). I have 3 combo boxes degined to Lookup each of the key
elements (cbo_Schema_Name_L, cbo_Table_Name_L and cbo_DataElement_Name_L).
Each combo box has a Row Source Property set to a query using the appropriate
filter(s). The queries are working fine.

The VBA wizard generated the following FindFirst command:

rs.FindFirst "[DataElement_Name] = '" & Me![cbo_DataElement_Name_L] & "'"

How to I code FindFirst to include all 3 data elements? The syntax of the
FindFirst command is very confusing to me.

Thanks,
-John
 
M

Marshall Barton

JHC said:
I have a table keyed by 3 elements (Schema_Name, Table_Name and
DataElement_Name). I have 3 combo boxes degined to Lookup each of the key
elements (cbo_Schema_Name_L, cbo_Table_Name_L and cbo_DataElement_Name_L).
Each combo box has a Row Source Property set to a query using the appropriate
filter(s). The queries are working fine.

The VBA wizard generated the following FindFirst command:

rs.FindFirst "[DataElement_Name] = '" & Me![cbo_DataElement_Name_L] & "'"

How to I code FindFirst to include all 3 data elements? The syntax of the
FindFirst command is very confusing to me.


If all three of the conditions must be specified then you
can use:

rs.FindFirst "[DataElement_Name] = '" _
& Me![cbo_DataElement_Name_L] & "'" _
& " And Schema_Name = '" & Me.cbo_Schema_Name_L & "' "_
& " And Table_Name = '" & Me.cbo_Table_Name_L & "' "_
 
J

JHC

Marshall,

Wow! Thank you so much.

rs.FindFirst "[DataElement_Name] = '" & Me![cbo_DataElement_Name_L] & "'" _
& " And [Schema_Name] = '" & Me.[cbo_Schema_Name_L] & "' " _
& " And [Table_Name] = '" & Me.[cbo_Table_Name_L] & "' "

Worked great.

Thanks,
-John

Marshall Barton said:
JHC said:
I have a table keyed by 3 elements (Schema_Name, Table_Name and
DataElement_Name). I have 3 combo boxes degined to Lookup each of the key
elements (cbo_Schema_Name_L, cbo_Table_Name_L and cbo_DataElement_Name_L).
Each combo box has a Row Source Property set to a query using the appropriate
filter(s). The queries are working fine.

The VBA wizard generated the following FindFirst command:

rs.FindFirst "[DataElement_Name] = '" & Me![cbo_DataElement_Name_L] & "'"

How to I code FindFirst to include all 3 data elements? The syntax of the
FindFirst command is very confusing to me.


If all three of the conditions must be specified then you
can use:

rs.FindFirst "[DataElement_Name] = '" _
& Me![cbo_DataElement_Name_L] & "'" _
& " And Schema_Name = '" & Me.cbo_Schema_Name_L & "' "_
& " And Table_Name = '" & Me.cbo_Table_Name_L & "' "_
 

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

Top