Set Variable to Field2 if Field1 = "textString"

M

Marty

What is the VBA code for this:

VariableName = Select Table1.Field2 From Table1 Where Table1.Field1 =
"TextValue"

I would like to set the VariableName to the value of field2 where field1 is
equal to a text string.

Thank you for taking the time to review and answer this for me.
Marty
 
K

Ken Snell [MVP]

Perhaps the DLookup function will do what you seek:

VariableName = DLookup("Field2", "Table1", "Field1 ='" & "TextValue" & "'")
 

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