DLookup Formatting Question

Huey462

Board Regular
Joined
Jul 25, 2011
Messages
147
I would like to have Access take the data directly from a table rather than load it into a global variable when the generate email button is pressed.

My question is how do I format the Dlookup to snag this data?

Table: tblLetterData
Field: RepLetterBody
ID: = 1
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Where exactly are you trying to do this?
On a Form (I am guessing, since you mention a button)?
And then and you trying to return this to a TextBox on your Form?
 
Upvote 0
Let's say that the Command Button is named "Command10" and is populating a Text Box named "txtLetter". Then the code would look something like this:
VBA Code:
Private Sub Command10_Click()
    Me.txtLetter = DLookup("[RepLetterBody]", "tblLetterData", "ID = 1")
End Sub
 
Upvote 0
Something alonng the lines of

Code:
objMail.Body = DLookup("RepLetterBody", "tblLetterData", "ID = 1")
 
Upvote 0
Thank you so much, it was the quotes around the ID that was giving me issues. I really do appreciate it.
 
Upvote 0

Forum statistics

Threads
1,221,545
Messages
6,160,447
Members
451,647
Latest member
Tdeulkar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top