Rabu, 24 Oktober 2018

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

 

Crystal,

After looking into your coding, which is amazing btw, I noticed that it is having me set the filter. I already have a filter string that is created in the form. Is there anyway that i can capture this string and insert it into this coding? Also, where exactly do i put this coding, i was hoping to be able to just use a command button. Here is a snippet of my coding that creates the filtering criteria that I was able to find and modify for use in my database.


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

__._,_.___

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

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