Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Access 2007: Add Filter to VBA Script controlling export of data to MS Word?

Posted on 2011-04-28
4
Medium Priority
?
351 Views
Last Modified: 2012-05-11
Hi everyone, I have a VBA script that experts here have crafted over time which exports selected fields (as captions) to a Microsoft Word document.  I know how to create a 'filter' in a SQL query with where clauses, but I would like to implement a method to do this on the form.  I wanted something similar to: http://allenbrowne.com/AppSearchHighlight.html (the highlighting is optional but I liked the search box with combo box populated by relevant fields).  I've tried to modify this code with my form 'MakeWordTable' but it doesn't seem to be working.  I've attached the database here if anyone can take a look at what I'm doing and try to help I'd very much appreciate it.  As of now I keep getting errors saying that it can't find the field I've inputted into the combo box.   If users think I am barking up the wrong tree with this approach let me know that as well and please offer another suggestion.  Even a simple solution would be excellent.  My ultimate goal is to perhaps have two or three methods for the user to filter the data on the MakeWordTable form.  

I'm attaching the file here if anyone is interested in looking.

Thank you so much,
Bevo
EE-AbsRev.mdb
0
Comment
Question by:Bevos
  • 2
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
Nico Bontenbal earned 2000 total points
ID: 35483206
In the Command2_Click after the line:
strSql = "select " & fieldlist & " from qryAll"
I've added these lines:
If Not IsNull(Me.cboField) Then
    strSql = strSql & " WHERE " & Me.cboField & " like '*" & Me.txtSearchText & "*' "
End If


Then I selected
show only where field Infection contains c
on the form, and this seemed to do the trick. It probably needs some tweaking, but I hope you get the general ID. If this is (more or less) what you need you can remove all the code from the cboField and txtSearchText controls.

0
 

Author Comment

by:Bevos
ID: 35486178
This works, jawesome nicobo.

So you are saying i should remove all code ascribed to items and it will still work?

0
 
LVL 22

Expert Comment

by:Nico Bontenbal
ID: 35489115
Yes, delete the
Private Sub cboField_AfterUpdate()
and
Private Sub txtSearchText_AfterUpdate()
procedures, and it will still work.
0
 

Author Closing Comment

by:Bevos
ID: 35489171
Thanks so much Nicobo!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question