I'm trying to use a DLookUp in my VBA code to populate a field based on another field. Both fields are in a table called Accounts. The field being populated is called EXP_ACCT and field the value depends on is REV_ACCT. I have written 2 different lines of code and they don't work. I tried it like this...
This code is inside a for loop. valRevAcctY2 is a field on the form. The ExpAcctFront & c gives me the correct ExpAccount box to populate.
I'm assuming it's something in my where clause of the dlookup that is causing the problem. Thanks for the help.
Code:
Me(pyExpAcctFront & a) = DLookup("[EXP_ACCT]", "Accounts", "[REV_ACCT]=Me![valRevAcctY1]")
Code:
Me(ExpAcctFront & c) = DLookup("[EXP_ACCT]", "Accounts", "[REV_ACCT]=" & "'" & Me![valRevAcctY2] & "'")
This code is inside a for loop. valRevAcctY2 is a field on the form. The ExpAcctFront & c gives me the correct ExpAccount box to populate.
I'm assuming it's something in my where clause of the dlookup that is causing the problem. Thanks for the help.