access email

cvboas

Registered User.
Local time
Yesterday, 16:12
Joined
Jul 31, 2006
Messages
20
I have this code to send email by a access form but its given errors in one variavel, "strHelpDesk" says that it is not defined. Can some one help me? tank you



the code is


Private Sub cmdMailTicket_Click()
On Error GoTo Err_cmdMailTicket_Click

Dim stWhere As String '-- Criteria for DLookup
Dim varTo As Variant '-- Address for SendObject
Dim stText As String '-- E-mail text
Dim RecDate As Variant '-- Rec date for e-mail text
Dim stSubject As String '-- Subject line of e-mail
Dim stTicketID As String '-- The ticket ID from form
Dim stWho As String '-- Reference to tblUsers
Dim stHelpDesk As String '-- Person who assigned ticket
Dim strSQL As String '-- Create SQL update statement
Dim errLoop As Error
'-- Combo of names to assign ticket to
stWho = Me.cboAssignee
stWhere = "vendedor.cod_vendedor = " & "'" & stWho & "'"
'-- Looks up email address from TblUsers
varTo = DLookup("[email_vendedor]", "vendedor", stWhere)

stSubject = "Aviso de Visita programada."

stTicketID = Format(Me.txtTicketID, "00000")
RecDate = Me.txtDateReceived
'-- Helpdesk employee who assigns ticket
strHelpDesk = Me.cboReceivedBy.Column(1)


stText = "Foi-lhe atribuida uma nova visita." & Chr$(13) & Chr$(13) & _
"This ticket has been assigned to you by: " & strHelpDesk & Chr$(13) & _
"Data da visita: " & RecDate & Chr$(13) & Chr$(13) & _
"Isto é uma mensagem automatica. Por favor não responda a este e-mail."

'Write the e-mail content for sending to assignee
DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1

'Set the update statement to disable command button
'once e-mail is sent
strSQL = "UPDATE email SET email.enviado = -1 " & _
"Where email.cod_email = " & Me.txtTicketID & ";"


On Error GoTo Err_Execute
CurrentDb.Execute strSQL, dbFailOnError
On Error GoTo 0

'Requery checkbox to show checked
'after update statement has ran
'and disable send mail command button
Me.chkTicketAssigned.Requery
Me.chkTicketAssigned.SetFocus
Me.cmdMailTicket.Enabled = False

Exit Sub

Err_Execute:

' Notify user of any errors that result from
' executing the query.
If DBEngine.Errors.Count > 0 Then
For Each errLoop In DBEngine.Errors
MsgBox "Error number: " & errLoop.Number & vbCr & _
errLoop.Description
Next errLoop
End If

Resume Next


Exit_cmdMailTicket_Click:
Exit Sub

Err_cmdMailTicket_Click:
MsgBox Err.Description
Resume Exit_cmdMailTicket_Click

End Sub
 
Hi,

You've dimmed it as sthelpdesk but you are using it as strhelpdesk


K.
 
I modified sthelpdesk for strhelpdesk but I receive a new message error “type of data incorrect in the expression of criterion"
 
cvboas said:
I modified sthelpdesk for strhelpdesk but I receive a new message error “type of data incorrect in the expression of criterion"

Which line is the error appearing on?
 
the first error its in the "strHelpDesk = Me.cboReceivedBy.Column(1)"
the second one dosen't show the line,it dosen't even open the vb code.
 
Hi,

Add a break point to your code - on the left hand side of the window with your code in is a grey bar that runs down the page - see attached pic - click on the bar next to the first line of your code. The line will be highlighted in burgandy/brown

Code:
stWho = Me.cboAssignee

Run the code as you would normally - button on a form i'd guess - when the break point is reached the code will stop running and highlight the line in yellow. Use the f8 button to step through the code one line at a time. You can then find out which line is causing the error.
 

Attachments

  • bp.gif
    bp.gif
    2.3 KB · Views: 170
I tried but I did not acheave. I am with the same error… I did not obtain to identify the error…
thanks
 

Users who are viewing this thread

Back
Top Bottom