Quote:
quote:Originally posted by Annie
sherr8, Did you receive a resolution to this issue? I am having exactly the same problem..ie. converted my Access Database to Access project, and the filter from the form will not work.
If if was resolved for you. could you let me know what you did.
Thanks
Annie
|
It's just a matter of converting the code to ado. Here is the code I used for the form I was having problems with. Let me know if this helps.
Option Compare Database
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private Sub cmdSendMessage_Click()
Dim strInvoice As String
Dim cnInvoice As ADODB.Connection
'connect to current database
strInvoice = CurrentProject.BaseConnectionString 'this works for adp only
Set cnInvoice = New ADODB.Connection
With cnInvoice
.CursorLocation = adUseServer
.Open strInvoice
End With
Dim strInvNo As String
Dim rsInvoice As ADODB.Recordset
' Send a message for invoices over 30 days from PM Date"
strInvNo = (txtInvoiceNumber.Value)
Set rsInvoice = New ADODB.Recordset
'CreateObject ("ADODB.Recordset")
With rsInvoice
.CursorLocation = adUseServer
Form_frmEmailProjectManagers.txtInvoiceNumber.SetF ocus
End With
If Now() - ProjectManagerDate >= 30 And IsNull(ReceivedApproval) Then
sendmessage "", "", "", "Expired Invoice", "Invoice Number " & strInvNo & " has expired. Please notify me with further information. Thank you"
Else
MsgBox "Message cannot be sent because invoice is not over 30 days!"
End If
Set cnInvoice = Nothing
Set rsInvoice = Nothing
End Sub
Private Sub sendmessage(strEmail As String, _
strCC As String, _
strBCC As String, _
strSubject As String, _
strBody As String)
On Error GoTo errorroutine
Dim stext As String
Dim sAddedtext As String
If Len(strEmail) Then
stext = strEmail
End If
If Len(strCC) Then
sAddedtext = sAddedtext & "&CC=" & strCC
End If
If Len(strBCC) Then
sAddedtext = sAddedtext & "&BCC=" & strBCC
End If
If Len(strSubject) Then
sAddedtext = sAddedtext & "&Subject=" & strSubject
End If
If Len(strBody) Then
sAddedtext = sAddedtext & "&Body=" & strBody
End If
'If Len(txtAttachment) Then
' sAddedtext = sAddedtext & "&Attach=" & Chr$(34) & Me!txtAttachment & Chr$(34)
'End If
stext = "mailto:" & stext
If Len(sAddedtext) <> 0 Then
Mid$(sAddedtext, 1, 1) = "?"
End If
stext = stext & sAddedtext
' launch default e-mail program
If Len(stext) Then
Call ShellExecute(Me.hwnd, "open", stext, vbNullString, vbNullString, SW_SHOWNORMAL)
End If
' Normal Completion
Exit Sub
errorroutine:
MsgBox Err.Description
End Sub
Private Sub Form_Open(Cancel As Integer)
'displays only the invoices that are over 30 days
Me.ServerFilter = "GetDate()-ProjectManagerDate>=30"
Me.Refresh
End Sub
slypunk