Dlookup Frustration

S

SandySun

Hi, I am having a problem with a Dlookup. I am trying to set up an Auto
email and I need to insert a formated number field in the Body of the
email...and I just can't seem to figure it out....can someone please help?
This is what I have so far;

Function SendByEmail(strtest As String, strEmail As String) As Boolean
On Error GoTo PROC_ERR
Dim strRecipient As String
Dim strSubject As String
Dim strMessageBody As Integer
strRecipient = strEmail
strSubject = "Sales Data"
strMessageBody = "Prior Day Sales " & DLookup("amountround", "Sales",
"Messageno = 0")
DoCmd.SendObject acSendNoObject, , , strRecipient, , , strSubject,
strMessageBody, False
SendByEmail = True
PROC_EXIT:
Exit Function
PROC_ERR:
SendByEmail = False
If Err.Number = 2501 Then
Call MsgBox( _
"The email was not sent for " & strEmail & ".", _
vbOKOnly + vbExclamation + vbDefaultButton1, _
"User Cancelled Operation")
Else
MsgBox Err.Description
End If
Resume PROC_EXIT
End Function
 
R

Robert Morley

You don't say HOW you want your number formatted, but probably you're
looking for something like:

.... Format(DLookup(...), "Currency")

(replacing the ellipses with your existing code, of course).

Using "Currency" will follow whatever your system is set to for currency.
So in the States, that would typically be $x.xx.

You can also hard-code it specifically if, for example, you're in the UK,
but you're always sending to the US and want to always show the amount in
standard US format. For more help on that, type in the above code, click on
the word "Format", then hit F1 for help. Then check out the various options
for Numeric formatting ("Different Formats for Different Numeric Values",
"Named Numeric Formats", "User-Defined Numeric Formats").



Rob
 
S

SandySun

Rob, I just knew it was going to be something crazy simple. Thank you very
much!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top