I need some of your expertise here.
I have a form frmEnterBill. On this form I have an Account# text box and a CompanyName text box (as well as some others). I have a table: Accounts with Account # and CompanyName. I have code in the AfterUpdate event of the Account# field in the form to populate the CompanyName textbox on the same form by pulling CompanyName from the Accounts table that matches the AccountNumber entered in the form. The code reads as follows:
No matter what Account Number I enter, I only get a CompanyName of my 2nd record in the Accounts table.
Can anyone suggest some update to my code to fix this?
Any help would be much appreciated.
Thanks,
RAY
I have a form frmEnterBill. On this form I have an Account# text box and a CompanyName text box (as well as some others). I have a table: Accounts with Account # and CompanyName. I have code in the AfterUpdate event of the Account# field in the form to populate the CompanyName textbox on the same form by pulling CompanyName from the Accounts table that matches the AccountNumber entered in the form. The code reads as follows:
Code:
Dim varCompName As Variant varCompName = Lookup "CompanyName", "Accounts", "AccountNumber_ =[AccountNumber] ") If (Not IsNull(varCompName)) Then Me![CompanyName] = varCompName
Can anyone suggest some update to my code to fix this?
Any help would be much appreciated.
Thanks,
RAY
Comment