test if a value is in a table with vb code

  • Thread starter Thread starter wimsan
  • Start date Start date
W

wimsan

LS,

how can i use VB to test if a certain value is in table A or in table B ?
so how can i make this if statement work :

if (value) in table(A) then A = value
if value in table(B) then B = value
 
Use DCount to see how many times the value is in the table. If 0, it's not
there. If 1 or greater, it is there.

If DCount("*", "[TableName]", "[FieldName]='" & Me.txtMyTextbox & "'") > 0
Then

You could also use DLookup. This might be faster since it "should" stop at
the first instance of the value and therefore not go through the entire
table.

If Not IsNull(DLookup("[FieldName]", "[TableName]", "[FieldName]='" &
Me.txtMyTextbox & "'")) Then
 

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

Back
Top