I know this is marked solved but I thought I would toss in my $0.02.
I see you are using text fields as primary keys.... this is considered a bad idea. Plus Long Integers are faster.
See http://www.bluemoosetech.com/microso...Primary%20Keys
Also, you might read
"7 Ways to Make Database Administration a Nightmare"
http://www.bluemoosetech.com/relatio...0a%20Nightmare
Be aware you have used reserved words, "TYPE" & "STATE", in two tables.
Here is a list of reserved words:
http://allenbrowne.com/AppIssueBadWord.html
As to the DLOOKUP(), I would write a UDF. Much cleaner IMO.
In a control, you would use
=GetTaxRate(CustomerLName, CustomerFName)
In a query, you could use
Tax:GetTaxRate(CustomerLName, CustomerFName)
The code
Code:
Option Compare Database '<<should be at the top of every module
Option Explicit '<<should be at the top of every module
Public Function GetTaxRate(PLName As String, pFName As String) As Single
Dim r As DAO.Recordset
Dim sSQL As String
sSQL = "SELECT StateTaxes.SalesTaxRate"
sSQL = sSQL & " FROM StateTaxes INNER JOIN Customers ON StateTaxes.StAbbr = Customers.Sta"
sSQL = sSQL & " WHERE CustomerLName = '" & PLName & "' AND CustomerFName = '" & pFName & "';"
Set r = CurrentDb.OpenRecordset(sSQL, dbOpenSnapshot, dbFailOnError)
If r.BOF And r.EOF Then
GetTaxRate = 0
Else
GetTaxRate = r.Fields("SalesTaxRate")
End If
End Function