Reports :: Automate Printing From A Command Button With Selected Data From A Query?

Jul 15, 2013

How can I automate different printers for different reports on the same MS Access 2007 database, without having to select the printer each time?

There are two reports that are printed on the same database. Previously, I had automated form buttons to print the reports, without having to select the printer each time. This was about 8 years ago, but I don't remember how I did this. Also, I don't know SQL. Nothing against code, but I did not know how to program, and just MS Access 2007 access itself.

View Replies


ADVERTISEMENT

Automate Mail Merge From Command Button

Feb 7, 2005

Hey guys,

I have spent a while surfing around the site for the answer to this problem but to no avail.

I have a form with a command button which when pressed opens a Word Document. It's a mail merge template and I want to be able to automate the actual merge (merge to new a new Word document) as soon as the Word document opens.

Any help with this would be greatly appreciated. I am using the code below and cannot get the objWord.MailMerge.Execute line to work.

Rusty
:D

Private Sub cmdOK_Click()

On Error GoTo Err_cmdOK_Click

' Declare variables
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String

'Dim objWord As Word.Document

' Get the database and stored query
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryMultiSelect")
' Loop through the selected items in the list box and build a text string
For Each varItem In Me!lstTrials.ItemsSelected
strCriteria = strCriteria & ",'" & Me!lstTrials.ItemData(varItem) & "'"
Next varItem
' Check that user selected something
If Len(strCriteria) = 0 Then
MsgBox "You did not select any Trials from the list." _
, vbExclamation, "Nothing to find"
Exit Sub
End If
' Remove the leading comma from the string
strCriteria = Right(strCriteria, Len(strCriteria) - 1)
' Build the new SQL statement incorporating the string
strSQL = "SELECT * FROM Trials " & _
"WHERE Trials.[Name of Trial] IN(" & strCriteria & ");"
' Apply the new SQL statement to the query
qdf.SQL = strSQL

' Open the MailMerge template
Call Shell("""C:Program FilesMicrosoft OfficeOfficeWINWORD.EXE"" ""O:ASWCSRecruitment dataCTU Cancer Trial Monthly UpdatesMonthlyUpdateTemplate.doc""", 1)

'objWord.MailMerge.Execute

' Empty the memory
Set db = Nothing
Set qdf = Nothing

Exit_cmdOK_Click:
Exit Sub

Err_cmdOK_Click:
Resume Exit_cmdOK_Click

End Sub

View 11 Replies View Related

Reports :: Create Query From Command Button And Export To Excel

Apr 22, 2014

In Access, it is possible to create a query from a command button and export to excel?

View 1 Replies View Related

Modules & VBA :: Enable Command Button When Item Selected From List Box

Oct 14, 2014

I have a simple listbox (single column, no multi-selection).I want to enable a command button when the user selects an item in the listbox / disable it if no items are selected.I'm using the AfterUpdate event of the listbox, as follows :

Code:

Private Sub lstOptions_AfterUpdate()
Select Case Me.lstOptions.ItemsSelected.Count
Case 0
Me.comConfirm.Enabled = False
Case Else
Me.comConfirm.Enabled = True
End Select
End Sub

But when I select an item from the listbox, and debug the code, the Count is always zero? Even though I can see the item selected??

View 2 Replies View Related

Reports :: Printing Multiple Reports From One Button

Apr 23, 2014

I have a form that produces Year end accounts, therefore each page is totally different from one another, there are 10 reports per set of accounts.

I have created 10 buttons that out puts the desired report

Profit and Lost, Balance Sheet etc.....

What I would like now is a way to print all 10 reports with the click of a button, how can this be done...

View 7 Replies View Related

Reports :: Multiple Report Printing From One Button

May 13, 2014

I'm trying to print out several reports from one button. I have created individual buttons for each of the reports and they work fine.

But when I try to amalgamate them it stops printing after the first two reports regardless of which ones are at the top of the list.

The code I'm using is ......

Private Sub Print_All_Click()
Dim strFilter As String
strFilter = "Business_ID = Forms!frm_Business!Business_ID"
DoCmd.OpenReport "rpt_Front_Page", acPrint, , strFilter
DoCmd.OpenReport "rpt_D_and_N_Suitability", acPrint, , strFilter

[Code] .....

View 5 Replies View Related

Reports :: Printing Report To PDF File Via Button On Search Form?

Aug 7, 2014

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:

DoCmd.OpenReport "Rpt_Event_internal", acViewPreview, "", "[Event_ID]=[Forms]![Search_Events]![Sub].[Form]![s_Event_ID]", acWindowNormal, ""

(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'm using Access 2013.

View 3 Replies View Related

Query In Forms Question (printing A Single Selected Query Record From A Form?)

Oct 19, 2004

What is the best way to impliment a query in a form so that the user can view the query records, and have the option to print or save the selected record using command buttons?

I tried subforms but I could not get the command buttons to work in the subform after it went into the form, it wanted to print the entire form instead of the selected record from the subform.

So in a nutshell I have 3-4 queries that are built, and I want to have them show up on my form in a format that the user can scroll through the results and select a single record of the results and then print or save that individual record from the form, if such a thing is possible.

Thanks in advance

Todd

View 1 Replies View Related

Reports :: Formatting A Report From A Command Button

Aug 21, 2013

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

View 2 Replies View Related

Reports :: Using Transfer Spreadsheet Command To Output Data In Query To Excel 2010 Format File

Aug 18, 2015

I'm working with Access 2010 and am trying to use the transferspreadsheet command to output data in a query to an Excel 2010 format file. Here is the line of code:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "q_calldetails_tmp", "c: emp estoutput.xlsx"

It works fine and produces the output file but when I try and open it with Excel I get an error saying the format is incorrect. If I change the extension to .xls it opens with no problem but I need it to be an Excel 2010 format with correct extension.

View 3 Replies View Related

I Need A Command Button To Print Preview And Email Two Reports

Oct 7, 2004

Like the title says I need a command button to print preview and email two reports. I tried using macros but the problem I have is that it'll send out two emails instead of one email with two attachments. The other problem is that it won't recognize current pages information so it'll show two blank reports. But If I go to next record and come back in form view, it reognizes the changes and the reports look fine. Any help would be appreciated.

View 2 Replies View Related

Reports :: Not All Data Is Being Printing Out

Jan 13, 2015

Not sure why this is doing this. When I print out my report, it will print most of the items, and leave some out. When I go back and check the information is in the database correctly, but it wont print out.

View 3 Replies View Related

Reports :: Using Command Button In A Form To Filter And Open A Report?

Jun 26, 2014

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

View 14 Replies View Related

Queries :: Command To Print Selected Query

Jul 11, 2014

I am trying to print selected query how can I do that what is the command for that ...

View 1 Replies View Related

Reports :: No Data Printing - Getting Single Blank Record

Jan 17, 2014

All i want to do is to print my report (with the records ideally!) which has a subreport header at the top but all i am getting is a single blank record?!

Surely this is not too much to ask but it is holding up the whole project!!!

View 2 Replies View Related

Using A Command Button To Input Data?

Jul 30, 2006

Hiya guys! This time around I need to know how to use a command button to input the date/time into a text field by the event OnClick.

I would have thought by inputting: VisitDate.Value=Date() it would have worked but no such joy.

Sorry if I sound really stupid! ;)

Thanks!

Jay

View 1 Replies View Related

Importing Data Using A Command Button

Mar 25, 2005

Good Morning to all:

I have created a form using Access 2000. Within this form are names address, Student ID'S, etc. In addition to this form, there are queries in there as well.

I wish to place a command button on this form so that when pressed, it imports data from another file(Excel). I assume the Excel file field names that I wish to import must match the table in Access 2000.

Is there a way to do this? I am completely lost.

Many, many thanks,

Dion

View 4 Replies View Related

Queries :: Printing Query Results Using A Button

May 10, 2013

I have a form that is set to display the results of a query into a subform... How can I get those results to a printer using a button. I don't need it to print the form just all the results that are in the subform.

View 3 Replies View Related

Programming A Command Button To Export Data

Nov 1, 2005

I know this topic has been discussed, but i could not find one thread on the general purpose of exporting an excel table/form to excel.

I would like to place a command button on my FORM, and let the user click this button and export the data into excel.

I tried using the transferspreadsheet method, but could not corrrectly, if at all get it working, and the help section within access2003 onlu covered importing into access from excel.

Please, if anyone has any links to sites/tutorials/ threads i misssed actually covering this topic/or thier own help, it would be greatly appreciated.

Thanks

Connor

View 2 Replies View Related

Command Button To Delete Data In Textboxes

Apr 9, 2005

Dear All:

I have created a form where data is entered. I wish to place a command button on the form and when it is pressed, it deletes data in specified textboxes. The texboxes are: LAST_NAME, FIRST_NAME, MIDDLE_NAME.

I assume this is done using vb, but I am clueless.

Any help is most welcome.

Regards,

Dion

View 2 Replies View Related

Modules & VBA :: Printing Code Slowing Down Printing Reports?

Feb 25, 2014

I was having trouble just setting each report with a particular print method - for some reason they just kept forgetting their individual settings and resorting to default on the machine.

This meant reports were printing on the wrong paper, or the wrong size paper, the wrong orientation and some times refusing to print if it couldn't find the paper (which is useful in runtime as it doesn't display error messages)

So I used Reports(rpt).printer properties (I forgot where I found this) to hard code the printer properties into each print command... this meant I had to use another function to insert the variables.

So all I had to do was say:

Code:
PrintMe("Invoice","InvoiceID",iID)

and a report would print to exactly how I wanted... but it's just too slow!

See attached for full code, I have a niggling feeling it may be the function: PrinterOK, to make sure the printer exists or not.

Code:
Function PrinterOK(sPrinterName As String) As Boolean
Dim MyPrinter As Printer
PrinterOK = False
For Each MyPrinter In Printers
If MyPrinter.DeviceName = sPrinterName Then
PrinterOK = True
Exit Function
End If
Next
End Function

I know it's the printing code, because if I stop the printing and just preview then it shows up almost instantly.

View 1 Replies View Related

Import Data Into Table From Excel Using Command Button

May 18, 2006

I'm looking for someone to help me with a solution to my problem of importing data into a data table.
What I'd like to do is have a command button on a form. When this button is clicked the records in a table are cleared out. Then I'd like for a browse window to come up to locate an Excel file. The user would select this file and the data would be imported into the data table that was just cleared.
Can this be done without too much trouble?

Thanks, Paul

View 4 Replies View Related

Command Button, Need To Lock Data And Insert Date.

Sep 14, 2006

Well the title says it all. I need to create a button to lock the info on the form so it can't be edited and at the same time insert the date. Any ideas?

View 1 Replies View Related

Forms :: Use Command Button For Switching Off Data Entry

Jul 4, 2013

Is it possible to have a command button on a form that when clicked will turn the data entry property from yes to no?

View 3 Replies View Related

Reports :: Adding Data To Report That Was Selected Using Combo Boxes?

Jan 21, 2015

I am using Access 2010 (self taught and continuing to learn each time I get asked for a new report). I have created a query based on the data being selected from two combo boxes on a form, ie start date and end date. The report works as it should but I want to be able to automatically use the dates in the report heading. For instance, Summary Report from xxxxx to xxxxx, where xxxxx is the start and end dates that the user entered into the two combo boxes.

The date field on my query reads
Between [forms]![F - CboReportDates]![Start Date] And [forms]![F - CboReportDates]![EndDate]

View 3 Replies View Related

Reports :: Macro That Opens Exports The Selected Data To A Form?

Feb 23, 2015

I currently require a macro that takes the record and when clicked, it opens a form and displays this record. This is so that I can use it to click buttons and open existing reports based on the data and field that match the 'clicked' record.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved