VBA ACCESS - SQL statement after Print - ms-access

In my DB i have a table called "PrintList" populated with a random number of records and a report called "ReportList", which is linked to "PrintList", that is used to print all the records of the table above.
EDIT: I would let the user to see a print preview in Access to check the list and then choose if print it or not, so i prefer to avoid using code to print.
Is it possible to handle the "ReportList" print event and delete all "PrintList" records after the report is printed? Right now I use a button to empty the list via SQL, but it will be more useful to empty it after printing it.

Report/section events like On Format or On Print are fired both for Print Preview and for actual printing. So the report doesn't know, and thus can't handle your requirement.
I'd use a form with buttons for Preview and Print, and delete the records when the form is closed (because you can't prevent the user from printing from the preview).
The whole requirement looks a bit strange, TBH.

Open your report in design mode.
If the properties pane on the right isnt visible, press F4 to make it visible.
In the properties pane, click on the Events tab.
Find the OnPrint event and click the little ellipses to the right of it to open a VBA window ready to accept your code for that event.

Related

When printing a Access Report that's open in Preview, why is it printing contents of a table?

I have a report Open in Print Preview mode. I have accomplished this using a button with the code:
DoCmd.OpenReport "rptNameHere", acViewPreview, "", "", acNormal
When I print using Ctrl+P, the report prints as expected. When I go to File>Print however, it sends the contents of a table to the printer. The table it prints is currently selected in the Navigation Pane, and the program is for some reason ignoring the currently open window. This happens for each different report that I open in this same manner.
Is there anyway to fix this behavior? This database will be distributed in .accde format with the Navigation Pane hidden. That particular table will always be selected by default because it is the top object in the pane.
I'm guessing the answer is one of three options: 1) When I Open a report using my On-Click event, some sort of code to also select it in the Navigation Pane; 2) An option or code somewhere that will force the program to print the open window and not the selected table; 3) A way to remove the Print entry from the File menu so the only option is for users to print with Ctrl+P.
Edit: Using Access 2016, which may make a difference. I've also confirmed this happends regardless of what is currently selected in the Navigation Pane, that item is what is sent to the printer.
Edit 2: I think this has to do with my Forms/Reports that have the "Pop Up" set to Yes. For any of those, the problem occurs. Whenever "Pop Up" is set to No, it does not.

enable command button on form while in filterbyform mode

I'm trying to put a pair of command buttons onto a form to enable users to:
enter filter criteria, then
after they enter the criteria, apply the filter
The first is easy enough with "DoCmd.RunCommand acCmdFilterByForm"
The second would work with "DoCmd.RunCommand acCmdApplyFilterSort", except that I can't figure out how to activate my command button "cmdApplyFilter". The code "Me.cmdApplyFilter.Enabled = True" throws a runtime error.
I've looked at a lot of discussions, and it seems the only way to do this is by clicking on the ribbon or quick access toolbar. Does anyone know how to activate a command button on the form while in filter by form mode?
I'm pretty sure that what you're trying to achieve is not possible. The 'filter by form' view of the form looks to be a copy of your original form with only the input controls enabled to allow you to enter your filter criteria. If you think about it, it wouldn't make sense to allow full functionality. If you could activate buttons in this mode then you would theoretically be able to perform all sorts of actions that aren't appropriate in this context: add records, delete records, navigate through the records etc.
I suspect that the only way you will be able to get the functionality you want without using the ribbon bar buttons (what's wrong with the ribbon bar?) is to hand-roll your own filter form. Design a new form having controls to accept filter criteria and buttons to cancel or apply the filter. Sounds like a lot of hard work though to replicate functionality that's already built into Access out of the box.

Hyperlink box (txtbox) on Access Form won't allow drop

I have a MS Access form that is bound to a query in the database. I added a textbox and added a row source to a Hyperlink datafield in the query. When I open the form, it won't allow me to drop a file into the textbox.
Here's the deal. When I follow this EXACT same process on a new form, it works perfectly. That is, I open a blank form and I bind the form to some new query, let's say qryNewIdeas. Then on the blank form i add a textbox, let's say Text0. Then, when I select Text0, I go to the data tab - row source and choose the dropdown arrow to select the hyperlink field, lets say NewIdeasAddress. I click SAVE and open the form. It works PERFECTLY.
BUT, when I repeat this on an existing form (the one where I need the thing to actually work), it does nothing. It adds and changes the textbox to a hyperlink box (I note this because of the blue underlined word that appears in the box). But it won't allow me to drop files to this location.
I tried commenting out ALL of my VBA code to try to make sure that something wasn't hindering it (say in an OnLoad event) AND I've checked all of the form and control box properties and they seem to be the same in both the existing form and the test form.
I can't determine why it works on one form and not the other; Solution needed.
If you have access to "the data tab - row source ..", you are in design view.
When you later open the form, you are in form view, a completely different animal which specifically prohibits design changes.
It sounds like you will have to rethink your concept.

How to make a button in ssrs

There is a report contains 1000s of pages of data.Is there any way to make a button on the first page of the report so that ,if click on the button it goes to the end of the pages.
Is there any expression to be written,with out writing the vb.net code?
There is a button like that in SSRS (you can also type page number in the box and press enter):
EDIT:
You can add a bookmark at the end of your report and then make a textbox which will jump to it (textbox properties->Action->mark "go to bookmark" and select the bookmark you made. I am not sure, however, if it works well in excel.
Web viewer control, this button already exists.
I don't believe you can add a button to SSRS and export to Excel to go to last row.
You can use Excel command to go to last cell which should work.
Refer to [http://office.microsoft.com/en-ca/excel-help/excel-shortcut-and-function-keys-HP010073848.aspx][1]
CTRL+G
Displays the Go To dialog box.
F5 also displays this dialog box.
Click on "Special..." button and select "Last Cell" option and click OK
Sorry .. Tried posting images for you but not enough points to do so.
There are 2 ways of reaching the last page or the data on the last page:
Sol 1. #kyooryu has already mentioned above in his solution along with a screenshot.
Sol 2. You can freeze the header and set the display result to show the data on a single page. This way you will not have multiple pages and you can directly hit the end button from keyboard on the report manager to reach the bottom result set. Freezing the header will help you in identifying the column names.

How to show only "filled in" fields on an Access report

I have created a report for Microsoft access and am trying to add fields to a report only if then have been clicked on our filled out. The only way I can think of doing this is writing a code or an if-then statement in access. I have very little experience with writing code and am not sure where to begin. I'm looking for something like "If a checkbox is selected then add it to the report".
Thank you.
Instead of trying to dynamically add controls to a report you could include all of the fields on the report and then simply hide the controls that correspond to empty fields. For example, if you have a text field named [SpecialRequirements] and your report contains a bound text box named [txtSpecialRequirements] then in the On Format event handler of the report's Detail band you could use
Me.txtSpecialRequirements.Visible = (Not IsNull([SpecialRequirements]))
which is just a shorthand way of saying
If IsNull([SpecialRequirements]) Then
Me.txtSpecialRequirements.Visible = False
Else
Me.txtSpecialRequirements.Visible = True
End If
This should get you started - its a basic if structure:
If Me!myCheckBox = True Then
'Write to the report
Else
'Do something else
End If
Also check out the Microsoft Developer Network here for information on the If...Then..Else statement
This is really old, but I had the same issue above, but found a easy solution.
Go to Design view in your "report"
Make your Yes/No boxes not visible
Go to the Design tab in your tool bar
Click on the Controls and click on the Check box and place them over your Yes/No box
Delete the label it gives with the check box
Save and look at your report
Only the YES will appear as a checked box.