Results 1 to 6 of 6
  1. #1
    clrockwell15 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jun 2017
    Posts
    23

    Command Buttons and Forms

    I have a database with multiple contacts. Each contact is marked as either active or inactive. I have a form that is built on a query showing me just the inactive contacts. What I want to do is when I do a "Search" to find a certain contact, I want to click a command button I want to put on the form to show a preview of a report based upon the data that is active in the form I have open. Can it be done?

  2. #2
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Why not just run a query of either Active or Inactive contacts and use this as your record source for your reports. You can then view the data before you run the reports. A button can be added to your form to run the query to preview the report. Create the query in the QBE. Name it. Add a button to your form. Use the Wizard to link it to your query.

  3. #3
    clrockwell15 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jun 2017
    Posts
    23
    I know I can do that, but let me try to explain another way. I have a number of contacts. I need to go into my form, do a search for a particular contact, then press the "Inactive Letter" button to activate a report preview which I can then print.

  4. #4
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529

  5. #5
    clrockwell15 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jun 2017
    Posts
    23
    I really appreciate your input. Now, I am trying to understand the process. I am familiar enough with Access to create a database, create input forms, create reports and some queries. When it gets to the nitty gritty of what I want, I do run into a little problem grasping. I have a table with active and inactive contacts. They are marked as such with one field showing either "A" for active and "I" for inactive. I have forms built based on queries such as a query showing "I" (inactive contacts). When I open that form, I might have 20 or 30 inactive members. What I am trying to do is if I do a "Search" for a particular inactive member and that contacts' data is showing in the form, I just want to press a button that gives me a print preview of a certain report with that persons data on that report.

  6. #6
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    So you should have a member ID field, correct? It is a unique value? (the PK field?)

    The syntax for the OpenReport command is
    Code:
    DoCmd.OpenReport "Report1", acViewPreview, , "MemberID = " & Forms!YourFormName.MemberID
    The bold part is the WHERE clause in the command.

    Change "Report1" to the name of your report and "YourFormName.MemberID" to your form name and control/field name.

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

Similar Threads

  1. Replies: 4
    Last Post: 01-20-2017, 08:16 AM
  2. Replies: 2
    Last Post: 04-01-2016, 11:13 AM
  3. Replies: 5
    Last Post: 01-16-2013, 03:48 PM
  4. VBA coding for forms and command buttons
    By bakerri2 in forum Access
    Replies: 1
    Last Post: 05-31-2012, 11:29 AM
  5. Command buttons to Open Forms
    By Ace Pioneer in forum Access
    Replies: 1
    Last Post: 11-30-2010, 06:32 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