Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    carlmdobbs is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Location
    Maryland
    Posts
    26
    To do what you are asking requires skill in MS Access VBA code. Essentially you must know VBA and SQL to created the means to call up the report based upon criterion. Let me go into as much detail as I can.



    Let us say you have a form called "frmthisForm" with a field called "ThisField" that you want to place criterion in for the report. You would write code into the On Click event. (If you don't know how to do this then you should really call an instructor to explain how because this is not child's play. You can write me back and I can answer your questions in detail if you want. You rename the button to a meaningful name, like "btnopenReport." Then, in design view still, right click the button and choose "Build Event" from the pop-up menu. Then choose "Code Builder." In the code you will see the on-click sub procedure started for you. in the body of this procedure you'd make a reference to the value the user put in the "ThisField" field. You would then make a statement with SQL syntax

    dim x
    x = me!thisfiled

    Now depending on the nature of x, whether it is a number, a text or a date, you'd have to write the sql criterion statement to pass to the report. it would look something like this if the value were a number:
    "thisfield = " & x

    If it were a text you'd write:
    "Thisfield = '" & x & "'" where it x is enclosed with apostophes.
    If this were a date field the field would be enclosed in pound signs instead of apostrophes.

    This is the criterion statement so you would do the following:

    DoCmd.openreport "rptThisReport", "ThisField = " & x

    The report would open up to the criterion specified on your form for the field "Thisfield" where "Thisfield" is also in the recordset that the report is based on in its Recordsource property.

    I hope this helps.

  2. #17
    WhatnThe is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Posts
    50
    Hello Carl,

    I have the code within my form now. The issue is I recieve a Run-Time error 3075 if I don’t enter a part number The form I have right now is incomplete with only 2 fields but when it’s done it will have more. I know what the error is but I don’t know how to get around it. The form field I have within my form now is Press & Part Number. What do I do if I only want to enter information in the press field

    Right now it looks like the only field that is getting the information I want is the PartNumber. Even when I enter information in the Press field it appears that it’s ignored when I get the report. Please see the attached file. Is it possible to enter the PartNumber and the Press and narrow the results down even further?
    Last edited by WhatnThe; 02-01-2010 at 03:39 AM.

  3. #18
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    There are other issues but is this what you were trying to accomplish with your report form?

  4. #19
    WhatnThe is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Posts
    50
    Yes & No RuralGuy

    I wanted to be able to narrow down the resulats by entering data in both fields, but when I enter just a Press and run the report I get the Run-Time error 3075.

    Looks like I am going to need to create many form based on the data I want to get a report on.

    Can you tell me what other issues there are?

  5. #20
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You do not need "many" forms, only one will do. Just test for empty empty controls while creating the WhereCondition string. Explaining how to program and describing all of the issues is beyond the scope of a thread on this forum. You will need to start a new thread as you encounter the issues.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Cannot edit reports in Access 2007
    By sconard in forum Reports
    Replies: 3
    Last Post: 12-23-2009, 08:06 AM
  2. Access Reports using Northwind '07 form
    By racerklm in forum Reports
    Replies: 0
    Last Post: 11-09-2009, 09:08 PM
  3. The ampersand sign (&) and Access reports
    By tigers in forum Reports
    Replies: 2
    Last Post: 09-28-2009, 08:23 AM
  4. Formating a control in MS Access Reports
    By Alex Motilal in forum Access
    Replies: 3
    Last Post: 11-15-2008, 09:09 PM
  5. Access Reports
    By Mxcsquared in forum Reports
    Replies: 18
    Last Post: 01-04-2006, 10:32 PM

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