?
Solved

VBA: Get text from combo box

Posted on 2007-03-18
4
Medium Priority
?
1,165 Views
Last Modified: 2013-11-27
I have a form and am using the below code to try to send the text of a combo box using SMTP.  The email works, but it comes out like so:

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\EMAIL\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Maintenance Request

Submitted By: 3783
Time Requested: 3/17/2007 5:12:35 PM
Work Type: 3
Priority: 1
Location: Bay-A
Asset: BP-002
Problem Description:  vvvvv
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Now, this is basically what I want, but if you can tell, for example on the "Requestor" it shows a number.  In my combo, this is actually text, but the combo is bound to a number so I can understand why it does this.  Below is the code I have been trying to just use the actual TEXT of the combo versus its value with no success.  I have tried "me.reqid.text"  and "reqid.text" amoung other things with no success.

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\VBA CODE\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

 Dim objCDOMail As Object
      Set objCDOMail = CreateObject("CDO.Message")
    objCDOMail.To = "--SOME EMAIL--"
    objCDOMail.FROM = "--SOME EMAIL--"
     objCDOMail.Subject = "MAINTENANCE REQUEST"
   objCDOMail.TextBody = "Maintenance Request" & vbCrLf & vbCrLf & "Submitted By: " & Me.reqid & vbCrLf & "Time Requested: " & Me.DateRec & vbCrLf & "Work Type: " & Me.WorkType & vbCrLf & "Priority: " & Me.WorkPriority & vbCrLf & "Location: " & Me.LocationNo & vbCrLf & "Asset: " & Me.AssetNo & vbCrLf & vbCrLf & "Problem Description: " & Me.ProbDesc    
    objCDOMail.configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objCDOMail.configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ""
    objCDOMail.configuration.Fields.Update      
    objCDOMail.Send
    Set objCDOMail = Nothing
0
Comment
Question by:chrisryhal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Expert Comment

by:FrivolousSam
ID: 18743616
Why not look up the name using DLookup:

DLookup("[Name]", Requestors, [reqid] = " & Me.reqid)
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 18747269
I don't understand what you are refering too.  Could you please provide an example?  If you need the table name, its called "Employee's".
0
 
LVL 39

Accepted Solution

by:
stevbe earned 2000 total points
ID: 18747852
If you are displaying the name in the combobox (and I bet you are) you need to determine which column it is in ... colyumns are 0 based so if the first (and bound column) is the ID and the second column is the name ...

 objCDOMail.From = Me.cboRequestor.Column(1)

Steve
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 18897465
stevbe,

That column thing is what I needed.  Thank you VERY much!!!!!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question