Reports :: Where Condition When Opening A Report With A Button
Oct 22, 2014
Basically when I click a button on a form I want it to run a report but only when certain criteria are met as entered in the 'Where Condition' box. I've managed to do this successfully when it is an equal to query but I now want to run a 'contains' query and don't really know where to start.
I have a text box on the form labelled [Desc] and I want the report to pull records where any text entered in the [Desc] text box is contained in the fields [Used Stock]![Model]
I am trying to hide a text box based on the contents of another text box in the same report. Here is the code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) If IsEmpty(Me.DocFullName) Then Me.Text55.Visible = False Else Me.Text55.Visible = True End If End Sub
i.e. I want Text55 to disappear if DocFullName is empty.
I thought my code was OK, but it refuses to co-operate.
My Acess2000 database holds records of members of an organization which I manage. I've got a button on my most-used form, called 'local members and helpfulness', which opens a report designed to print one envelope, using address data from the current member record showing in the form. I did this by configuring the button execute a macro. The button's 'On click' event is set to the macro name: 'mcrPrintC5env':
It works fine; the report shows up in preview mode so that I can click 'print' to print off that single addressed envelope. However, if I put an identical button on another form which uses the same data from the same "local members list" table (via a different query), it doesn't work. When I click the button in form view, a popup input box appears.
So I have a report that opens via Parameter. The SQL behind the query that runs the report is (I took out alot of lines that aren't necessary to answer the question)
PARAMETERS [Enter Your Box Id] Short; SELECT DocumentsTable.OrganizationalID, . . . DocumentsTable.Status FROM DepartmentsTable INNER JOIN (Year1 INNER JOIN DocumentsTable ON Year1.ID = DocumentsTable.RecordDateYearID) ON DepartmentsTable.ID = DocumentsTable.DepartmentID WHERE (((DocumentsTable.Voided)<>'Y' Or (DocumentsTable.Voided) Is Null) AND ((DocumentsTable.ID)=[Enter Your Box ID]));
So if I click on the report, I get a little popup that says "Enter Your Box ID", and when I do, the report works just as expected.
However, I also want to be able to open this report via link from another report, and pass the Box ID #. I just can't get the syntax right. I would have thought it was this:
Private Sub ID_Click() DoCmd.OpenReport "Find A Box", acViewReport, , "[Enter Your Box Id]=" & Me.ID End Sub
However when that execute, I still get the pop up asking for "Enter Your Box ID"
I have a database with loads of different sales data from Jan 2014 with other product details as well. I also have a form where the user can input any of these data (this is based on a query):
- Campaign name - Exact Date - Month - Year - Category - Campaign Type
This should run the query, then open a report that's grouped by:
1. Year 2. Month 3. Exact Date 4. Dem name
Even if the user inputs the month and year on the form, when reopening the report, it prompts for inputting the year and month as well, but nothing else.
I've made a query and designed a report for it. Simply it includes:
Area code, customer name, other customer details.
I want other people, when they click on the report to be given a drop down box which allows them to choose a specific area code before it generate the report. So, for example, they just want to look at Yorkshire region records, they choose Yorkshire from the drop down box and it'll generate the Yorkshire report. I've searched around but can't find what these are called.
i have a button opening forms however when they open they appear in window mode and not full screen. is there an option or a line of code of code i am over looking to make it open in full screen mode?
I am trying to run a report based on a combobox selection. I have three different reports, each for the three different items in the combo box. I just don't know how to code it so when I run the report, it picks up the name in the combo box and opens the correct report. This is what my code looks like for the button that will run the report:
Private Sub Command7_Click() DoCmd.OpenReport ("Signers Authorized for Check Writing"), acViewPreview, , WhereCondition = [BTrans] = "Check Writing" DoCmd.OpenReport ("Signers Authorized for Stop Payment"), acViewPreview, , WhereCondition = [BTrans] = "Stop Payments" DoCmd.OpenReport ("Signers Authorized for Wires"), acViewPreview, , WhereCondition = [BTrans] = "Wires" End Sub
The problem is, that as soon as I hit the Run Report button, all three reports open up, so it is not reading what is in the combo box. The quotes, "Check Writing" , "Stop Payments" and "Wires" are the actual selections in the combobox and [BTrans] is the name of the combobox.
I have a main Form "Client" that shows details such as Representatives, phone numbers, status, etc. I also have a main report "CRM" that is a nicer summarized table version of all of my Client form entries.
The "CRM" form will be used by others in my office to see what clients we are contacting, etc. What I want to be able to do is have someone open the CRM form first. If they want to see even more specific info (not everything is included in the report, as that would be too messy), I want them to be able to double click the Client's name on the report and be taking to the corresponding entry on the Client form that shows more details.
Right now my code for the Report which is not working is the following:
Private Sub Client_Name_DblClick()'double click on a client name in the reportDoCmd.OpenForm "Client", acNormal, , "[Client_Name]='" & [Client_Name]'this should open the Client Form to the record of the same client that was double clicked on the reportEnd Sub
I have a report which is accessed via a hyperlink in a form. I have the default view for the report set to Print Preview yet everytime I click the link the report opens in report view which I don't want.
The event for the hyperlink is as follows:
Private Sub cmdPrint_Click() Dim strWhere As String If Me.Dirty Then 'Save any edits. Me.Dirty = False End If
[Code] .....
I have tried changing "acViewPreview" to "acViewReport" and "acViewNormal" and each time it is either going straight to print or opening in report view. I just want the report to open in print preview mode so I can decide if to print a hard copy or send to pdf.
I have a report which shows a set of events. In this report each row has a sub report which show the guests that are attending. What I would like to do is to use a button to drill down into each individual event and hide it again on clicking the button (like a toggle button). I have used the following code which is attached to a button in the report (each event has a button)
Code: If Me.GuestSubReport.Visible = True Then Me.GuestSubReport.Visible = False Else Me.GuestSubReport.Visible = True End If
I have used this in conjunction with the 'Can Grow' option and it works almost perfectly. The only problem is it shows or hides all sub reports at the same time instead of just the sub report in the given row.
Is there a way I can target the individual sub report when pressing the button?
I have a fairly simple report which lists rows from one table with a little bit of logic. At the end of each row, I want an action button, which when you click it, goes to a form with the correct ItemID for that row.I tried the VBA code like this on the View button on click method:
Of course, what happens is it opens the form CreateCAF with the first ItemID in the report, regardless of which row you click on. I want it to pick up the ItemId of that row.
What I want to be able to do is have a button next to every client entry which the user can click. Once the button is clicked, I want the "person name" box in the report to be formatted to have a yellow background.The purpose of doing this is so after a couple of days when we come back to the report, we can easily see by the yellow background which people we have to follow up with.
I don't think conditional formatting will work because I have so many different "person names" in the report that it would go above the 3 rule limit, only solution in VBA.The button I created is called "Format", and this is the VBA code I have tried:
Private Sub Format_Click () Me.Person_Name.BackColor = vbYellow End Sub
How can I set the record source of a report to a saved query through VBA. I am trying to use the same report for a number of uses, all of the info on the report is the same, but the only difference is the query that the information is based on. I have this simple code below, how do I add a record source to it (if it can be done)
Dim stDocName As String Dim stCriteria As String stDocName = "Rallies this year" stCriteria = "[Year of Rally] = " & Year(Date) MsgBox (stCriteria) DoCmd.OpenReport stDocName, acViewPreview, "", "", stCriteria
the output in the msgbox is [Year of Rally] = 2013 which seems fine but the OpenReport command then gives me a type mismatch error the [Year of Rally] is a calculated field in the query - the record source.
I have tried
stCriteria = "[queryname].[Year of Rally] = " & Year(Date)
I have a database with several reports that get constantly printed, however I am having an issue with their display properties that sometimes cause errors.I need the report to come up on top of everything, maximized and with the menu bar available to allow for it to be printed or close it. The report window cannot have "minimize" or "restore" available to make sure nobody access any form behind it.
To achieve this in a form I generally use the modal property, however if I do this in a report I cannot get to the menu bar to print or close the print preview.Thinking that modal was out of the question, I went ahead and maximized the report on load and set its properties to the image attached. The db is then compiled (accde) and then distributed.
On my computer (it is being developed on my machine) the report loads fine (maximized) with no min, max or restore buttons and the print preview menu bar is shown with the print and close buttons available. See "My PC" image attached.On any other computer, the report opens up maximized but the report's restore and close buttons are enabled, however the print and close buttons on the print preview menu bar are greyed out. See "Other PC" image attached.Why the inconsistent behaviour when using the same front end?
I have a report that is a summary of multiple records in it. What I have next to the record on the report is a button.I have report that are labeled:
rptIncident Summary rptIncident Report and a button labeled "open report"
I would like to click on the button and then it open the rptIncident Report with all the information, not just the summary. I will put a picture so you know what I am trying to accomplish.Is this a simple Onclick event with a where condition or what? Or does this go beyond to having something to do with VBA?
I'm building an application to record engineer input in Events (jobs) for an engineering company.
My main tables are Products, Builds and Events, together with fifty or so reference and ancillary tables which aren't really relevant to this particular head-scratcher.
A Build is derived from a Product and an Event is applied to a Build. An Event includes a sale, a service, a warranty repair and so on. Over time, multiple Events will be logged against a Build.
I have a searchable Events form (Search_Events), containing a subform (Search_Events_sub) whose contents dynamically change to reflect data entered in a variety of unbound fields in the main Events search form. Needless to say, the glue that holds things together is the Event_ID field.
On my Search_Events form, I'd like to place two buttons (Rpt_Event_client and Rpt_Event_internal) which will allow the user to print either a client or an internal copy of the event in question. The reason I want to use separate buttons rather than one button for both copies is that it's quite likely that different engineers will work on different parts of an Event's build, test and sign off process, and will want to print off and annotate the internal report, whereas only the final report will be sent to the client. Also, there will be some slight differences between the visible fields on each report (time and materials logged etc).
So far, I've managed to get the Rpt_Event_internal button to open the relevant Event report in preview mode, using the following on the button's 'on click' event:
(In the subform, Event_ID is referenced as s_Event_ID because I'm using an nZ function in most of the search fields so that the results filter dynamically)
So far, so good: this works fine. However, from a usability perspective, and based on the fact that this will be the most-used feature, I'd really like to be able to have the button do the following:
- print the relevant report, based on Event_ID as above to a PDF file
- synthesise the filename of the report along the lines of "Event_" & [Event_ID] & "_Client_Copy_" & [Date()] & ".pdf"
- and to then have the standard 'save as' Windows location browser/file explorer dialogue box appear so the user can choose where to save the file. I don't want the filepath to be hardwired, rather I need the users to be able to decide where to save the file.
I added a "print preview" button to a report that does just that, shows the print preview. The issue I'm having is that I can't do anything in Access after I click that button. Everything in Access seems to stop working, I can't click on anything with my mouse. the only thing that does anything is that i can move the report up and down with the up/down/left/right keys. If I click on a different application that isn't Access (i.e. excel, spotify, email, etc.) and then go back to it, everything works fine.
I'm trying to use a command button in a form to filter and open a report. I am able to get it to open the report, but I cannot get it to filter the report based on a combobox in the form. I've tried every combination of code I could think of and find. Here is what I currently have:
Code: Private Sub FilterReport_Click() DoCmd.OpenReport "Report", acViewReport, "First Name='" & Me.FName & "'" End Sub
Code: Option Compare Database Private Sub Report_Open(Cancel As Integer) Me.RecordSource = Me.FName End Sub
"FilterReport" = Form Button "Report" = Report "First Name" = Report Field "FName" = Form Combo Box
I have a retort that I want to use an option button to filter the report is a specific date is 48 hours before the current time. I'm not having any luck. Below is the code I have been playing with, but no go.
Private Sub NoMove_Click() Select Case Me.NoMove.VALUE Case 1 Me.Filter = "CLM = 'Now() - 48'" Me.FilterOn = True End Select If Me.Filter = "" Then MsgBox "The filter returned Null" Else End If End Sub
I am wondering, is it possible to have a were condition for a button to a table? I want to click the button, close the form I have, and open up my sales table, and have it have a were condition to be like what I have for my form
Code: ="[EventID]=" & [lstShows]
I have that for the form, and it works, I am just not sure if I can use that for a Table. that "code" us being used in a openform macro. If there isnt a way to use a macro, how about VBA code?
I have a main form (Parent) along with a subform(Children). I want to have a button that generates a report with the Parent information as a header and the items in the subform as details. In addition, I want the report to show only the children that were recently added not all of the children.