SHOW ALL BUTTON can show in report preview MS ACCESS - ms-access

I'm not very expert in using this Microsoft access, I just try my best and try to follow the tutorial on youtube. I'm stuck with showing all records in the preview report. for now when I select the place that I want, the preview report just showing the selected places. But when I click the show all button and I click the preview report, it still comes out with selected places, not all records. Any changes that I need to change at the 'show all' button?
Private Sub cmdshowall_Click()
Dim showall As String
showall = "SELECT * FROM Register"
Me.RecordSource = showall
Me.Requery
Eng Sub

Related

Coding a label or text box in access on a report

What I am trying to accomplish: I have a report built that feeds from a button on a form and the info selected on that form. What I need is a code that will allow the report to change the header caption based on the information selected from the print report button on the form. So essentially on my form I have three fields that are drop downs. When I make my selection on the first two fields and I want a report that lists only that information I hit the button that says print report and it works just fine. What I want it to do is when I hit the print report button it will open the report with the a specific title based on what selections were made from the form. So for example on my form I choose the branch from the drop down then I choose an organization from the drop down. When I hit the print report button I want that report to open with the Title of the branch and the organization. I want it to be able to change each time the selections are changed. Essentially update the information from the form to the title or caption of the report. Any suggestions? I found a code I thought would work but I cannot make it work when I tweak the information. I am fairly new to the coding and access world and would appreciate any help.
Here is the code I was trying to use:I was trying to figure out how to add snipping photos I took but don't know how. Here is the code I was trying to use I solved the problem by passing the new text for the Label.Caption in the "OpenArgs" parameter in the OpenReport command, and used the Open Event for the Report to install the new Caption. It works great!
Code:
>>> In Control Form Module
Private Sub Command0_Click()
Dim aWhere As String
Dim aStrArg As String
'Select a WHERE statement (from Global List) based on the Radio Box Group
aWhere = aDept(Me.Dpt_Chain.Value)
'Pass a String Argument to the Report to install in the Label
aStrArg = "TEST 22"
'Open the Report and pass it a string ...
DoCmd.OpenReport "Price_1", acViewPreview, , aWhere, acWindowNormal, aStrArg
End Sub
>>> In Report Code - Form opens with "TEST 22" in the Label
Private Sub Report_Open(Cancel As Integer)
If Not IsNull(Me.OpenArgs) Then
Me.Controls("Dpt_Label").Caption = Me.OpenArgs
End If
End Sub
I tried to tweak it to work with mine but can't. this is not my information for my stuff but I thought by tweaking this code I could make my caption/title box on my report change each time different information was selected in my form.
Tested, and this worked for me:
Dim strString As String
strString = "Hallllo"
DoCmd.OpenReport "Report1", acViewReport, , , , strString
Private Sub Report_Open(Cancel As Integer)
Me.Controls("Label1").Caption = Me.OpenArgs
End Sub

Opening multiples a report in more than one tab (Access Database)

I have an access database that has a report. There is a button I click to open it, and everything works fine if I just want one report. However, if I want to open the same report twice, say to compare the two, it does not work. Instead of opening the second report in a separate tab, it just takes me to the tab that has the first report on it. Is there a way that I can make the report always open in a new tab?
You can achieve this quite easily, with a little VBA. You do need to add a module to the report and to the form/report with the button:
On the buttons on click event:
Public Sub MyButton_Click()
Dim rpt As New [Report_Labels and Remarks]
rpt.Visible = True
Set rpt.Myself = rpt
End Sub
On the report, in the module:
Public Myself As Report
Private Sub Report_Unload(Cancel As Integer)
Set Myself = Nothing
End If
Note that you might need to rewrite other code, like macros closing the report, DoCmd.Close and code fetching values from the report using the Reports collection, since there are multiple instances of the report.

Label Hyperlinks on MS Access 2013 Reports

I am having troubles with being able to click hyperlinks on reports in MS Access 2013. My database serves the function of a project log which tracks what projects our group is working on. The hyperlinks serve as an attachment to a summary file (usually PPT) for each project. Each project is a record in my backend table.
So far I have:
Stored the hyperlink as a string in a database table
Pull/edit/add hyperlink to a record via Access forms
Show the hyperlink and click on it via Access forms
Add the hyperlink on a report by referencing a hidden textbox which houses the path
The problem is that the hyperlink shows up on the report correctly and sometimes I am able to click on it, but the majority of the time I cannot click on it. If I scroll around the report, sometimes I can get the hyperlink active but it seems hit or miss.
Here is the code I used to apply the hyperlink on the report:
Private Sub Detail_Paint()
Dim strSource As String
If Report_rptCompleted.txtHL.Value <> "" Then
strSource = Report_rptCompleted.txtHL.Value
Report_rptCompleted.lblHL.Caption = Right(strSource, Len(strSource) - InStrRev(strSource, "\"))
Report_rptCompleted.lblHL.HyperlinkAddress = strSource
Report_rptCompleted.lblHL.ForeColor = vbBlue
Else
Report_rptCompleted.lblHL.Caption = "No Attachment"
Report_rptCompleted.lblHL.HyperlinkAddress = ""
Report_rptCompleted.lblHL.ForeColor = vbBlack
End If
End Sub
Any help on resolving this issue would be greatly appreciated
I ended up having to go a different route and use a text box instead of a label.
My solution was to drop the label and OnPaint event entirely. I formatted the textbox to show the file name then referenced the file path in the OnClick event with a FollowHyperlink command.
It is a good bit slower opening the link but works fine.

How can I make a checkbox print one report if checked, another if left unchecked?

I am using Access to print employee reports and I have built a search form to facilitate this and query these reports. I have detail and summary reports and I want to make it so I only have one button for the open report, preview report, and print report buttons, instead of one set for detail and one set for summary. Here are a couple of pictures to illustrate what I need.
This is what I have currently.
And this is what I want.
How can I configure the checkbox to open/preview/print out the detail if unchecked and summary if checked? Also I'd prefer to not use VBA code if possible - as managers who don't know code let alone Access very well will have to use this in the future.
Any help would be much appreciated!!!!!
You will have to use VBA for this in your OnClick event of the button:
Dim ReportName As String
If Me!CheckSummary.Value = True Then
ReportName = "NameOfNormalReport"
Else
ReportName = "NameOfSummaryReport"
End If
DoCmd.OpenReport ReportName

Access 2010 form with command buttons - OpenQuery and PrintPreviewQuery

I have created an access 2010 form where I have a listbox and two command buttons. Listbox includes all of the query names and command button one is for "query print preview" and the command button 2 is for "opening the query" which should be same as "double clicking the query name" in the listbox. So, how do I make these buttons and queries to open when double clicked in the list work?
Edit: I've updated my answer with the generic code you would need to open a query via the button or the Listbox. This assumes that the values in the Listbox are valid query names within your database.
This is easily done with a little VBA.
Option Explicit
Private Sub List_DblClick(Cancel As Integer)
Call Show_Click
End Sub
Private Sub Show_Click()
DoCmd.OpenQuery Me.List.Value
End Sub
This assumes that your listbox is called List. And your command button is called Show.
Basically, the code you want run in the button's Click event and call that sub from the list box's DblClick event.