HTML Email Body code

What is wrong with this code?  All works fine until I add the DLookup line

    strHTMLBody = _
        "<htmltags>Per the attached documents please quote best price and delivery for: <br><br>" _
        & Forms!frmQuotation.subfrmQuotationDetails.Form!txtPartNo & " - " _
        & Forms!frmQuotation.subfrmQuotationDetails.Form!txtPatternDescription _
        & "<br><br>" & _
        Me.txtPatternSpecInstructions _
        & "<br><br>" & _
        "Thank you for your prompt attention to this request." _
        & "<br><br>" _
        & DLookup("[Name]", "tblQuotationPreparers", "[ID] = " & Me.txtQuotationPreparer) _
        & "<br><br> </htmltags>"

Open in new window

SteveL13Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
test this

     Dim strName As String
     strName = DLookup("[Name]", "tblQuotationPreparers", "[ID] = " & Me.txtQuotationPreparer)
     strHTMLBody = _
        "<htmltags>Per the attached documents please quote best price and delivery for: <br><br>" _
        & Forms!frmQuotation.subfrmQuotationDetails.Form!txtPartNo & " - " _
        & Forms!frmQuotation.subfrmQuotationDetails.Form!txtPatternDescription _
        & "<br><br>" & _
        Me.txtPatternSpecInstructions _
        & "<br><br>" & _
        "Thank you for your prompt attention to this request." _
        & "<br><br>" _
        & strName _
        & "<br><br> </htmltags>"

Open in new window

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
what's the error you encountered?

>>DLookup("[Name]", "tblQuotationPreparers", "[ID] = " & Me.txtQuotationPreparer)
few things to check:
-Make sure in your table: tblQuotationPreparers, there's a field called "Name"
-Make sure in your table: tblQuotationPreparers, there's a field called "ID", which contains numeric values
-Make sure Me.txtQuotationPreparer is not blank and contains numeric value
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
If the ID value in tblQuotationPreparers is a Text field, then add single quotes around your value:
   
strHTMLBody = _
        "<htmltags>Per the attached documents please quote best price and delivery for: <br><br>" _
        & Forms!frmQuotation.subfrmQuotationDetails.Form!txtPartNo & " - " _
        & Forms!frmQuotation.subfrmQuotationDetails.Form!txtPatternDescription _
        & "<br><br>" & _
        Me.txtPatternSpecInstructions _
        & "<br><br>" & _
        "Thank you for your prompt attention to this request." _
        & "<br><br>" _
        & DLookup("[Name]", "tblQuotationPreparers", "[ID] =' " & Me.txtQuotationPreparer & "'") _
        & "<br><br> </htmltags>"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
I think Scott simply typed too fast (an extra space), it should be as:

& DLookup("[Name]", "tblQuotationPreparers", "[ID] ='" & Me.txtQuotationPreparer & "'") _

instead of

& DLookup("[Name]", "tblQuotationPreparers", "[ID] =' " & Me.txtQuotationPreparer & "'") _

(No point for this comment pls)
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
@SteveL13

So is that mean your ID is a char field?
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
I left the space there so you could easily see the single quote. Meant to do it at the end too, but I forgot.
Rey Obrero (Capricorn1)Commented:
;-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.