Rabu, 24 Oktober 2018

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

 

hi Matt,

and now you see why no one else answered ... no solution to this without using code.

If you do not need to filter the form, then you don't have to call that procedure -- but, depending on what you're doing, the Where clause of OpenForm might not work ...

Before you can assimilate the help you've been given, you need a better foundation. Buckle up, take some deep breaths, and get started with VBA. That is where the power of Access gets unleashed!

Learn VBA
http://www.AccessMVP.com/strive4peace/VBA.htm

Hope this helps.

respectfully,
crystal

ps
PLEASE, when you reply, include the prior messages so everyone can see what is going on, thank you


On 10/24/2018 11:09 PM, matthew.randolph83@yahoo.com [MS_Access_Professionals] wrote:

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: crystal 8 <strive4peace2008@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (7)

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