I have an button when clicked sends and email then updates my current data. I also need it to clear the form but not the information in the database.
Code:
Private Sub CmdUpdate_Click()
Dim notesdoc As Object
Dim notesrtf As Object
Dim notessession As Object
Dim strEmail As String
Dim strCopy As String
Dim strBCC As String
Dim i As Integer
Set notessession = CreateObject("Notes.Notessession")
Set notesdb = notessession.GetDatabase("", "")
Call notesdb.openmail
Set notesdoc = notesdb.CreateDocument
Call notesdoc.ReplaceItemValue("Subject", "Asset Transferred")
Set notesrtf = notesdoc.CreateRichTextItem("body")
Call notesrtf.AppendText(Me.body1)
Call notesrtf.Addnewline(1)
Call notesrtf.AppendText(Me.Manufacturer)
Call notesrtf.AppendText(" ")
Call notesrtf.AppendText(Me.DeviceType)
Call notesrtf.AppendText(" ")
Call notesrtf.AppendText(Me.model)
Call notesrtf.Addnewline(1)
Call notesrtf.AppendText("Serial Number")
Call notesrtf.AppendText(" ")
Call notesrtf.AppendText(Me.[Serial Number])
Call notesrtf.Addnewline(1)
Call notesrtf.AppendText("Asset Number")
Call notesrtf.AppendText(" ")
Call notesrtf.AppendText(Me.[Asset Number])
Call notesrtf.Addnewline(1)
Call notesrtf.AppendText(Me.body2)
strEmail = Me.txtemail
strCopy = ""
strBCC = ""
notesdoc.SendTo = strEmail
notesdoc.CopyTo = strCopy
notesdoc.BlindCopyTo = strBCC
Call notesdoc.Save(True, False)
notesdoc.SaveMessageOnSend = True
Call notesdoc.Send(False, strEmail)
Set notessession = Nothing
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE [Hardware Asset]" & _
" SET [Hardware Asset].[Assigned] = """ & 0 & _
""" WHERE [Hardware Asset].[AssetNumber] = """ & Me.AssetNumber & """"
DoCmd.RunSQL "UPDATE [Hardware Asset]" & _
" SET [Hardware Asset].[Status] = """ & 1 & _
""" WHERE [Hardware Asset].[AssetNumber] = """ & Me.[Status] & """"
DoCmd.RunSQL "UPDATE [Assignment History]" & _
" SET [Assignment History].[AH_Date_UnAssigned] = '" & Me.[Date Unassigned] & _
"' WHERE [Assignment History].[AH_Assigned_to_LoginID] = '" & [Forms]![Main Page Navigation Form]![SideTabNaviForm].[Form].[AssetAssignmentForm].[Form].[AH_Assigned_to_LoginID] & "' And [Assignment History].[AH_Assinged_AssetNumber] = '" & [Forms]![Main Page Navigation Form]![SideTabNaviForm].[Form].[AssetAssignmentForm].[Form].[AssetNumber] & "' And [Assignment History].[AH_Date_Assigned] = #" & [Forms]![Main Page Navigation Form]![SideTabNaviForm].[Form].[AssetAssignmentForm].[Form].[AH_Date_Assigned] & "#"
DoCmd.RefreshRecord
End Sub