Set Variable to Field2 if Field1 = "textString"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Perhaps the DLookup function will do what you seek:

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