Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLookUp Syntax Question

Status
Not open for further replies.

Ebes1099

Technical User
Jul 8, 2009
156
US
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...

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.
 
Hi
instead of:
Code:
"[REV_ACCT]=Me![valRevAcctY1]")

try:
Code:
"[REV_ACCT]= [red][b]" & [/b][/red]Me![valRevAcctY1])

without [red]"[/red] at the end!

Ja

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top