email VB code need some help

versuviusx

Registered User.
Local time
Today, 02:56
Joined
Nov 1, 2006
Messages
15
ok this project is for a help desk. if a user has a problem with their computer they fill out a form and then send an email to the helpdesk guy being me.
i got it to work but i'm trying to make improvements.
basically i get an error that says" you can't reference a property or method for a control unless the control has focus"
basically i'm trying to create a string.
and i want to grab a value from a box that the user enters and make that value a string. then i want to insert that string into the StrTitle for the email.
the result should look like "help desk Support number: 23" in the email title.
i was thinking the syntax should look like

strTitle = "helpdesk Support" + "incident Number:" + strIncidentNumber

i tried making strIncidentNumber.text and that did not work. i can't figure it out. i'm really new at this but i would have thought my logic would have been correct. please let m know. i'd love to get this working.



this is what the code looks like:


Private Sub SendEmail_Click()
On Error GoTo Err_SendEmail_Click

Dim strIncidentNumber As String
Dim strCCName As String
Dim strTitle As String
Dim strMessage As String

strIncidentNumber= SupportNumberTxtBox.text

strCCName = "david@wrar.com"
strTitle = "helpdesk Support" + "incident Number:" + strIncidentNumber
strMessage = "please help i need help with this"

DoCmd.SendObject , , acFormatRTF, strCCName, _
, , strTitle, strMessage, False, False




Exit_SendEmail_Click:
Exit Sub

Err_SendEmail_Click:
MsgBox Err.Description
Resume Exit_SendEmail_Click

End Sub
 
Change this:

strIncidentNumber= SupportNumberTxtBox.text

to

strIncidentNumber= SupportNumberTxtBox
 
awesome. thanks so much for that help. for some reason that worked.
also how do i comment stuff out in access with vb.
i've tried
******

and

///////
and those don't work. i want to be able to have comments for documentation
so later on someone can come through the code and see what i have done.
thanks again for the fast response.
 
That worked because the default property if none is specified is .Value, which is really what you wanted. The control has to have focus to use .Text, and it's rarely necessary to use it anyway.

Comments are a great idea. The character you want is a single quote:

'this line will be commented out
 
formatting the way the information looks

also how do i format the way the information looks in the emaiL?

for example i have this code:
strMessage =strIncedentDate+ strComplaint+ str+ str

well i want the email to look like this:
"
11/1/06

computer didn't work

low priority"


basically i want each string to be on different lines so someone can read it vertically from up to down versus left to right.
 
paul
you are the man. i haven't done this stuff in a while and i need a way to refresh on all this stuff. it's kind of fun. i like it so far. but it's only fun if you are making progress. once you get stuck for days on a problem...man does that Suck. thanks again man
david
 
No problemo. Others helped me when I was getting started; I'm just returning the favor. To answer your question:

strMessage =strIncedentDate & vbCrLf & strComplaint & vbCrLf &...

You can use more than one to add more lines between.
 
awesome. it would be nice if there was a little book that showed all the shortcuts. often i find there are books that show this info but it's cluttered with all kinds of blah blah and it takes for ever for me to get through it. also i find they show examples but they are not clear because they are not finished or maybe they touch on principles but not specific applications. thanks for the info. i will try it.
 
for some reason my dates are not showing up in the emails that i'm sending to my self. any reason. i have a text box that has a date format and i made it a string. am i gonna have to convert it from something to a string so it can work?
 
It's not in your original code. How are you setting it? It should work with just:

blah & Me.DateTextbox & whatever
 
paul

i'm declaring the strIncidentDate as a string.
the name of the dropdown box that contains the date is named:IncedentDateTxtBox.
my code looks right but i do not know why it is not showing up. after i make changes i save all my stuff and then i send my self an email through access. then i check outlook and see the results and for some reason the date is not coming through.

here is my code:

Private Sub SendEmail_Click()
On Error GoTo Err_SendEmail_Click

Dim strIncidentNumber As String
Dim strCCName As String
Dim strTitle As String
Dim strMessage As String
Dim strComplaint As String
Dim strIncidentDate As String
Dim strUserName As String
Dim strPriority As String
Dim StrProblemType As String


strIncidentNumber = Me.Suppot_NumberTxtBox
strComplaint = Me.complaintTxtBox
strIncidentDate = Val(Me.IncedentDateTxtBox)
strUserName = Me.NameDrpBox
strPriority = Me.PriorityDrpBox
StrProblemType = Me.ProblemDrpBox

'these strings below are what i'm using to insert for email address,subject and Message

strCCName = "david@wrar.com"
strTitle = "Helpdesk Support Needed" + " // " + "Incident Number " + strIncidentNumber
strMessage = "incident Date:" + strIncedentDate & vbCrLf & "UserName:" + " " + strUserName & vbCrLf & "Priority Level:" + " " + strPriority & vbCrLf & "problem type:" + " " + StrProblemType & vbCrLf & "Complaint:" & vbCrLf & strComplaint


'this code below sends off the email

DoCmd.SendObject , , acFormatRTF, strCCName, _
, , strTitle, strMessage, False, False




Exit_SendEmail_Click:
Exit Sub

Err_SendEmail_Click:
MsgBox Err.Description
Resume Exit_SendEmail_Click

End Sub
 
you spelled it wrong

strIncedentDate
 
Last edited:
For starters, while you may get away with using "+" as a concatenation operator, I would use "&". They will behave differently in certain circumstances. I'm not sure what effect the Val() function is having on your value, but I wouldn't use it. Here's a snippet from something I'm working on (also sending an email/fax), and as you can see I just use the textbox directly:

strBody = strBody & strBold & "Date requested: " & strBoldOff & Me.ReqDateTime & varLineBreak _
 

Users who are viewing this thread

Back
Top Bottom