Results 1 to 4 of 4
  1. #1
    Candy_Tech is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Jan 2017
    Posts
    6

    Command Button

    Hello all,
    I am attempting to create a command button to search for specific data within my report.



    Backround:
    I created a report design that looks like a nutritional label; within the report I have data that was pulled from a table.
    One of the textboxes in the report design is called "item_number". This textbox contains all of the items numbers for products my company carries.

    What I want to do:
    I want to create a command button to search for the "item number" in my report design.

    Issues I'm having:
    I have tried to create a command button to do my desired action. However, I can only get a command button to search for data in a query or table. How do I get the command button to search for data in my report design?

    Any help is greatly appreciated

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    1. you dont search data in a report, just the data
    2. there is no data in 'report design'
    3. you can search data in the query the report is connected to.

  3. #3
    Candy_Tech is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Jan 2017
    Posts
    6
    Hello,
    Thank you for your response ranman256.
    I am not experienced in micosoft access, so please bear with me.
    Below is what my report looks like in design view, and print preview. ( maybe this will help make sense of my situation)
    As you can see there are text boxes in my report that are filled with data from a table. I want to make a command button search through the data in a specific textbok "item number"
    If this is not possible, how do I connect a query to my report?



    Click image for larger version. 

Name:	Screenshot (6).jpg 
Views:	7 
Size:	95.2 KB 
ID:	26981
    Click image for larger version. 

Name:	Screenshot (7).jpg 
Views:	7 
Size:	97.8 KB 
ID:	26982

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    The proper approach here is to run the report so that it shows only the data you want. A common way of doing that is to have a form which you use to select the data you want (perhaps from a combo box), and to put a command button on the form to create the report once you have made the selection.

    Supposing you have a combo named "cboSelectItem" on your form, and you have selected an item from the list.

    The command button would run a bit of code something like this:

    DoCmd.OpenReport "ReportName", , "ItemID = " & me!cboSelection

    The part in RED is the WhereCondition for the report, and it specifies which record will be included in the report.

    Check the VBA help for more information on the OpenReport method of DoCmd.

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

Similar Threads

  1. Replies: 3
    Last Post: 03-29-2015, 07:42 PM
  2. Replies: 1
    Last Post: 09-12-2014, 06:09 AM
  3. command button
    By angie in forum Access
    Replies: 10
    Last Post: 12-15-2013, 04:19 PM
  4. Replies: 3
    Last Post: 08-04-2013, 07:11 AM
  5. Replies: 1
    Last Post: 07-27-2010, 02:27 PM

Tags for this Thread

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