visual basic coding send

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Visual Basic Coding to send an reminder when approaching an Expe

Visual Basic Coding to send an reminder when approaching an Expe

resolvedResolved · Urgent Priority · Version 2003

Manjeet has attended:
Access VBA course

Visual Basic Coding to send an reminder when approaching an Expe

Hi,

I am trying to send a reminder email when approaching a particular date.

The email coding is working, however when the number of records that are approaching the Expected Completion Date are to be displayed an error message is being displayed
'Wrong number of arguments or invalid property assignment.

I have copied and pasted the coding and the above error message displays highlighting the DCount wording.

Private Sub Form_Close()

Dim intStore As Integer, lngNoDays As Long, strLogClosed As String

Dim LValue As Integer
'intStore = DCount("[ITLLogNumber]", "[tblItlrequestlog]", "[txtLoggedclosed] =Yes")
intStore = DCount("[Log Number]", "[tblItlrequestlog]", "[txtLoggedclosed]", _
"[txtECDDate] <=Now() AND [Complete] =Yes")
If intStore = 0 Then

If MsgBox("There are " & intStore & "emails to be sent" & _
vbCrLf & vbCrLf & "Would you like to send them now?", _
vbYesNo, "You have outstanding emails to be sent...") = vbYes Then
' send an email
Dim AnyData As String, Var
Dim dbData As DAO.Database
Dim rstLogFile As DAO.Recordset
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 '--The ITL log no from form
Dim stHelpDesk As String '--Create SQL update statement
Dim errLoop As Error

'Set dbData = CurrentDb
'Set rstLogFile = dbData.OpenRecordset("ITLRequestLog1", dbOpenTable)
'rstLogFile.MoveFirst
'rstLogFile.MoveLast
'Var = rstLogFile![ITLLogNumber]

'rstLogFile.Close
'dbData.Close

'insert email information here
'--Combo of names to assign ticket to
'stWho = Me!["ITL Request Log1"]
'stWhere = ("ITLRequestLog1") = " & " '" & stWho & "'"
'-- Email address from
stWho = Me![txtLoggedby] '"manjeet.marwaha@equitygroup.co.uk"

'string of details being pulled in from table

stSubject = "::ITL Request Log Closure Email - Log No::" & Me.[txtITLLogNumber]
stLoggedby = Me.txtLoggedby
stTel_Ext = Me.txtTelext
stUnderwritingref = Me.txtUnderref
stScheme = Me.txtErscheme
stSchemeBuildType = Me.cboSchemebuild
stDepartment = Me.cboDepart
stSoftwarehouse = Me.cboSoftwarehouse
stProduct = Me.cboProducttype
stFulldesofproblem = Me.txtFulldescriptionproblem
stAllocatedto = Me.cboAllocatedto
stCatergory_typeofsubmission = Me.cboCategory
stPriority = Me.cboPriority
stecddate = Me.txtECDDate
stFinalcomments = Me.txtFinalcomments
stLogclosed = Me.txtLoggedclosed
stLogclosuredate = Me.txtDateclosureemailsent

'Information that will be sent in the Email
stText = "ITL Request Log Closure Email." & Chr$(13) & _
Chr$(13) & "Logged By: " & stLoggedby & Chr$(13) & _
Chr$(13) & "Tel/Ext: " & stTel_Ext & Chr$(13) & _
Chr$(13) & "Underwriting Ref: " & stUnderwritingref & Chr$(13) & _
Chr$(13) & "Scheme: " & stScheme & Chr$(13) & _
Chr$(13) & "Scheme Build Type: " & stSchemeBuildType & Chr$(13) & _
Chr$(13) & "Department: " & stDepartment & Chr$(13) & _
Chr$(13) & "Software House: " & stSoftwarehouse & Chr$(13) & _
Chr$(13) & "Product: " & stProduct & Chr$(13) & _
Chr$(13) & "Details of Request: " & stFulldesofproblem & Chr$(13) & _
Chr$(13) & "Your Request Has been allocated to: " & stAllocatedto & Chr$(13) & _
Chr$(13) & "Category: " & cboCategory & Chr$(13) & _
Chr$(13) & "Priority: " & stPriority & Chr$(13) & _
Chr$(13) & "Expected completion Date: " & stecddate & Chr$(13) & _
Chr$(13) & "Final comments: " & stFinalcomments & Chr$(13) & _
Chr$(13) & "Log Closed: " & stLogclosed & Chr$(13)

'The command below sends the email out
DoCmd.SendObject , , acFormatTXT, stWho, , , stSubject, stText, True


'LValue = DateDiff("d", -45, ECDdateFromTable, Now)

' Exit Sub
' Else
'MsgBox("There are " & intStore & "emails to be sent" &
'vbCrLf & vbCrLf & "Would you like to send them now?", _
'vbYesNo, "You have outstanding emails to be sent...") = vbYes
'Else
'Exit Sub

Else
End If
End If
Else
' equals Yes so check training issue

End If

End Sub

Please could you advise as soon as possible.

RE: Visual Basic Coding to send an reminder when approaching an

Hi Manjeet

Thanks for your post and information provided. We had a look at the only way we can assist is to view your actual working files and troubleshoot the code.

This takes us away from the forum and into consultancy. If you would like to discuss this further please reply to my email.

Kind regards

Jacob

Thu 26 Aug 2010: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Access tip:

Hiding Multiple Table columns

If you want to hide non-adjacent Access table columns. In Datasheet view, open the table that contains the columns you want to hide.

On the Format menu, click Unhide Columns.
In the Unhide Columns dialog box, clear the check box next to the name of each column you want to hide.
Click Close.

This method makes having to use the Hide Columns command repeatedly unnecessary

View all Access hints and tips


Server loaded in 0.09 secs.