Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VBA: Get text from combo box

Posted on 2007-03-18
4
Medium Priority
?
1,166 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

636 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