Results 1 to 5 of 5
  1. #1
    waltb is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2011
    Location
    CT
    Posts
    23

    Mailing Labels from a Search Form

    I have a Search form (frmSearch) based on the method of Allen Browne (http://allenbrowne.com/ser-62.html) which I highly recommend as it creates queries on the fly. It is based on a query (qrySearch). I can easily export the results to Excel with a short VBA code I found (Send to Excel). What I need is to create labels from these results. I have created a report to generate labels using the Access 2007 Label wizard. This report is also based on the same query as the Search Form.

    I thought that if I obtain my search results I could simply send these to the label Report using a macro ("Open Report"). Unfortunately all I get is ALL RECORDS RETURNED, not the search form subset of records in front of me.

    I am unable to base the labels Report on the Search Form. Any ideas? Can this be done with a Macro or is it strictly VBA? If VBA, is there an example I can follow?

    Thanks in advance.



    Walt

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    How are you 'sending' the search results to Report? Are you setting RecordSource property or Filter property? Are you use the WHERE CONDITION argument of DoCmd.OpenReport?

    Show code for analysis.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    waltb is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2011
    Location
    CT
    Posts
    23
    Actually I haven't don't anything since I'm not fluent in VBA. I thought it might be as simple as building a macro to get the search results into the label report. Since I want this to be as simple as pushing a button ("Print Labels"), any VBA pointersto build an Event Procedure are welcome.

    Walt

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I use VBA only. My usual method of filtering a report is to use the WHERE CONDITION argument of DoCmd.OpenReport (also for OpenForm).

    DoCmd.OpenReport "report name", , , "criteria statement here"

    The criteria statement could be something like: "[ZipCode]='" & Me.zipcode & "'"

    Macro has equivalent code structure. To build VBA select [Event Procedure] in the event property and double click the ellipses (...). This will take you to procedure in the VBA code editor. Type code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    waltb is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2011
    Location
    CT
    Posts
    23
    Thanks! Actually, I found my answer after Googling around this morning..just needed to search on the correct wording. It was as simple as inserting a snippet of code into the OnOpen event of the label generating report (and substituting with the name of my Search Form):

    Me.Filter = Forms!UserSearchFormNameHere.Filter
    Me.FilterOn = True

    Here's the URL.
    http://bytes.com/topic/access/answer...ed-values-form

    Wouldn't have figured it out on my own. Works perfectly! Combined with Allen Browne's 'query on the fly' coding (above) it's the most efficient way to query and generate labels.

    Thanks again for responding.
    Walt

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Mailing list question
    By JoeyG54 in forum Access
    Replies: 3
    Last Post: 08-23-2011, 01:27 PM
  2. Replies: 7
    Last Post: 02-08-2011, 10:59 AM
  3. Replies: 10
    Last Post: 11-23-2010, 10:16 PM
  4. E-Mailing A Report (From a form)
    By adams.bria in forum Forms
    Replies: 3
    Last Post: 04-30-2010, 10:03 AM
  5. Form--Labels in Form Header
    By duckie10 in forum Access
    Replies: 1
    Last Post: 06-09-2009, 11:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums