Rabu, 24 Oktober 2018

[MS_AccessPros] Re: Mail Merg with access 2007-2016 Office 365

 

Crystal,

If this already posted I am truly sorry. I didn't see it in the thread. (I'm not really up to speed no forums or groups).


I looked through your coding, which is amazing and can't wait to see if it works, however, I also noticed that it is asking me to set up a filter. I already do this in the form in my database. Is there a way to capture that filter string and place it in this coding? Also, where exactly will i put this, I was hoping to just have a command button for the user to press and get some feed back i.e. msgbox. I have copied a snippet of my coding here that sets up the filter of the form. Please let me know what you think. Again, thank you.


Matt


'~~~~~~START CODE~~~~~~~~


Private Sub cmdFilter_Click()


Dim strWhere As String                  'The criteria string.
    Dim lngLen As Long                      'Length of the criteria string to append to.
    Const conJetDate = "\#mm\/dd\/yyyy\#"   'The format expected for dates in a JET query string.
   
    '***********************************************************************
    'Look at each search box, and build up the criteria string from the non-blank ones.
    '***********************************************************************
   
    'Start Date filter. Use the format string to add the # delimiters and get the right international format.
    If Not IsNull(Me.dte_start) Then
        strWhere = strWhere & "([TRAN_DATE] >= " & Format(Me.dte_start, conJetDate) & ") AND "
    End If
   
    'End Date filter. Use the format string to add the # delimiters and get the right international format.
    If Not IsNull(Me.dte_end) Then
        strWhere = strWhere & "([TRAN_DATE] < " & Format(Me.dte_end + 1, conJetDate) & ") AND  "
    End If
   
    'Filter by CLIENT CODE or Select all. coding for txtClientCode comes from the dropdown combobox cmbClient
        'To veiw actual coding do the following:
            '1. Open fmMain in Design mode
            '2. Right-Click on cmbClient combobox
            '3. Click on "Properties"
            '4. Select "Data" tab
            '5. Select the three "dots" at the end of "Row Source" field.
            '6. SQL string is shown (DO NOT ALTER ANY DATA, form will not function properly if coding is altered)
                'Coding is as follow: SELECT CLIENT_NAME, CLIENT_CODE FROM tblClients UNION SELECT " All", "" FROM tblClients ORDER BY CLIENT_CODE;
            '7. Coding for txtClientCode is placed in created in the section Privat Sub cmbClient_AfterUpdate()
           
    If Not IsNull(Me.txtClientCode) Then
        strWhere = strWhere & "([CLIENT_CODE] Like ""*" & Me.txtClientCode & "*"") AND "
    End If
   
    'Filter by Profit Code or Select all. coding for txtProf comes from the dropdown combobox cmbProfCnt
        'To veiw actual coding do the following:
            '1. Open fmMain in Design mode
            '2. Right-Click on cmbProfCnt combobox
            '3. Click on "Properties"
            '4. Select "Data" tab
            '5. Select the three "dots" at the end of "Row Source" field.
            '6. SQL string is shown (DO NOT ALTER ANY DATA, form will not function properly if coding is altered)
                'Coding is as follow: SELECT Profit_Cntr, Porfit_Code FROM tblProfitCnt UNION SELECT " All", "" FROM tblProfitCnt ORDER BY Porfit_Code;

            '7. Coding for txtProf is created in the section Privat Sub cmbProfCnt_AfterUpdate()
    If Not IsNull(Me.txtProf) Then
        strWhere = strWhere & "([prof] Like ""*" & Me.txtProf & "*"") AND "
    End If
   
    '***********************************************************************
    'Chop off the trailing " AND ", and use the string as the form's Filter.
    '***********************************************************************
    'See if the string has more than 5 characters (a trailng " AND ") to remove.
    lngLen = Len(strWhere) - 5
    If lngLen <= 0 Then     'Nah: there was nothing in the string.
        MsgBox "No criteria", vbInformation, "Nothing to do."
    Else                    'Yep: there is something there, so remove the " AND " at the end.
        strWhere = Left$(strWhere, lngLen)
        'For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
        Debug.Print strWhere
       
        'Finally, apply the string as the form's Filter.
        Me.Filter = strWhere
        Me.FilterOn = True
    End If
End Sub


'~~~~~~~END CODE~~~~~~~

__._,_.___

Posted by: matthew.randolph83@yahoo.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (6)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


SPONSORED LINKS
.

__,_._,___

Tidak ada komentar:

Posting Komentar