Hi all
I have a table "Branches" that has the fields "CustCode" ,"BranchNo" and "BranchName". I have another table "Jobs" where each record has a field "CustCode" and "Branch No".
I am using DLookup to look up various fields in various tables in order to construct a new record in the "JobDeliveryNotes" table. I am trying to look up "BranchName" from the "Branches" table" using 2 integer variables - intCustCode and intBranchNo (I have checked the values of these 2 variables just before the DLookup statement and they have the correct values in them).
The DLookup statement I have is as follows:
I cannot for the life of me work out the syntax for the second criteria.
I then tried using a Query which looks like this:
The SQL view looks like this:
When I run this query from within Access I get the expected results:
I changed my DLookup statement to this:
Which gives me this error:
Please help!
I have a table "Branches" that has the fields "CustCode" ,"BranchNo" and "BranchName". I have another table "Jobs" where each record has a field "CustCode" and "Branch No".
I am using DLookup to look up various fields in various tables in order to construct a new record in the "JobDeliveryNotes" table. I am trying to look up "BranchName" from the "Branches" table" using 2 integer variables - intCustCode and intBranchNo (I have checked the values of these 2 variables just before the DLookup statement and they have the correct values in them).
The DLookup statement I have is as follows:
Code:
DLookup("[BranchName]", "[Branches]", "[CustCode]= " & intCustCode & " AND [BranchNo]= " & intBranchNo)
I cannot for the life of me work out the syntax for the second criteria.
I then tried using a Query which looks like this:
The SQL view looks like this:
Code:
SELECT Branches.CustCode, Branches.BranchCode, Branches.BranchName
FROM Branches
WHERE (((Branches.CustCode)=[intCustCode]) AND ((Branches.BranchCode)=[intBranchNo]));
When I run this query from within Access I get the expected results:
I changed my DLookup statement to this:
Code:
strBranchName = DLookup("[BranchName]", "[qryDelBranchName]")
Which gives me this error:
Please help!