Search Database And Print Report

Nov 11, 2004

I've created a Report called "Labels". I would like to use a program mwalts gave
me that searches my database and then sends out a mass email. I would like to take
this program and instead of it searching the database and sending an email, have it search
my database and print out the results in a report.

Can someone tell me the command lines I would need to add to the following program to do this?
I would like to just take out the email parts of the code and just substitute them with the print
label parts.

Thanks.

Code:'Designed by M. Walts'Important information! this code requires a reference to the Microsoft DAO object libraryOption Compare DatabaseOption ExplicitPrivate Sub cmdEmail_Click()'will hold the dynamic SQL queryDim strSQL As String'will hold the WHERE clause portion of our SQL queryDim strWHERE As String'will hold all the recipients of this messageDim strRecipients As String'the recordset we will use to get the emails of the records that match our criteriaDim rst As DAO.Recordset'if there is input in the search criteria, then we will run the query and send the e-mailIf txtSearch <> "" Then'if you have more buttons, just add mosr cases (the value of the radio button'= the Case number, so Value of the State radio button is 1, etc.)Select Case opgSearch.ValueCase 1strWHERE = "WHERE State = '" & txtSearch & "'"Case 2strWHERE = "WHERE City = '" & txtSearch & "'"Case 3strWHERE = "WHERE Denom = '" & txtSearch & "'"Case 4strWHERE = "WHERE Conference = '" & txtSearch & "'"Case 5strWHERE = "WHERE Donor = '" & txtSearch & "'"Case 6strWHERE = "WHERE MailingList = '" & txtSearch & "'"Case 7strWHERE = "WHERE YouthPastor = '" & txtSearch & "'"Case 8strWHERE = "WHERE PrayerSupport = '" & txtSearch & "'"Case 9strWHERE = "WHERE PACTTrainer = '" & txtSearch & "'"Case 10strWHERE = "WHERE PACTPartner = '" & txtSearch & "'"End SelectstrSQL = "SELECT EMail FROM tblUser " & strWHERE'run the query and get the results into the recordsetSet rst = CurrentDb.OpenRecordset(strSQL)'Loop through the recordset and add all the EMailsDo While Not rst.EOFstrRecipients = strRecipients & ";" & rst!EMailrst.MoveNextLoop'remove the first ; from the strRecipientsstrRecipients = Right(strRecipients, Len(strRecipients) - 1)MsgBox strRecipientsDoCmd.SendObject , , , , , strRecipients, txtSubject, txtBody, Falserst.CloseSet rst = NothingEnd IfEnd Sub'stops a ' entered in the field from breaking the queryPrivate Function SQLSafe(safeMe As String) As StringSQLSafe = Replace(safeMe, "'", "''")End Function

View Replies


ADVERTISEMENT

Modules & VBA :: Print Report Based On Multi Search Not Working?

Jun 5, 2014

i have created a MultiSearch query witch puts my results in a list box.under it i have created a button wich i want to use to print a report with the criteria i select from my list box if there is more than one result.

Following is the Code i used for my button

On Error GoTo Err_Command60_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "ReportLable"
stLinkCriteria = "[ProductID]=" & Me![SearchResults]
DoCmd.OpenReport stDocName, , , stLinkCriteria
Exit_Command60_Click:
Exit Sub
Err_Command60_Click:
MsgBox Err.Description
Resume Exit_Command60_Click

Every time u press the button i get a message syntax error(missing Operator) in query expression

Now i have not used any code in my Query except for

Like "*" & [forms]![frmSearchFor]![SrchText] & "*"

Where i made the error

View 3 Replies View Related

Forms :: Print Report Based On Subform With Multiple Search Criteria

Jun 14, 2015

I have a problem printing a Subform that uses multiple criteria(in textboxes) as filters.

The search portion of the form works fine. The problem is I have created a report based on the subform and am using the following code to open/filter the report

Code:
Private Sub PrintBtn_Click()
Dim strCriterion As String
Dim strMsg As String, strTitle As String

[Code].....

View 3 Replies View Related

Reports :: Unbound Report - Print Preview OK But None Of Fields Print When Report Directly Send To Printer

May 25, 2013

I have an unbound form with an associated report. When the user hits the 'print' button on the form/screen, the report is launched in the background. In the On Load event of the report I populate the report fields from the forms field as so:

Code:
Me.txtAddrMainLine2 = "NAME " & UCase([Forms]![frm_OrderRx].[txtPatientName])

This works like a charm as long as I call the report in Print Preview mode (i.e. with acViewPreview). But if I send the report directly to the printer, none of the fields print.

I've read about using other report events to populate the fields (e.g., On Format and On Print) and also something about using TempVars to pass the data. But I haven't read anything that's clear and definitive about the full answer.

View 3 Replies View Related

Reports :: Search Results Report Shows All Database Records / Not Just Search Results

Apr 29, 2014

I have built a custom search form in a MS Access 2010 database so that users can find specific records to edit. After entering the search criteria and hitting a Search button, another form opens up that shows the search results. This second form includes a command button for generating a report of the search results.

Right now, the custom search form and the search results form are both working properly, but the search results report is showing every record in the database instead of just the search results. This is true whether I access the report via the command button in the form or the navigation pane. I'm not sure if I need to correct my VBA code or the report's properties.

View 4 Replies View Related

Can ASP Or ACCESS Create A Database Search Report?

Dec 30, 2005

Hey there, can anyone advise if the following is possible and if so how it might be done?

I have created a site using DWMX04, ASP & ACCESS.

I would like to be able to have some sort of report on what is being searched on the database.

Can this be done in ACCESS or by using ASP?

Any ideas or suggestions would be great.

Mally.

View 3 Replies View Related

I Want To Print A Report And Programmatically Set The Printer Name And 'Print To File

Jul 16, 2007

How can I print a report and at the same time programatically set the printer name and 'Print to File' option and set the path of this option?

View 1 Replies View Related

User Input To Search Database And Create Report

Sep 9, 2004

I have a database that I created that uses a form to fill out information about server builds. I contains information about who built it, the IP address, server name, etc. I want to be able to create a dailog box that allows the user to input a server name to query the database and create a report based on that input. And if the user input isn't found in the database, a dialog box comes up with some sort of error message. I am still pretty new to Access, so the more detail you can give me the better. Thank a lot.

View 1 Replies View Related

Find Command In Access In One Report To Search Throughout Whole Database

Dec 7, 2014

Is there a way to use the find command in access in one report to search throughout the whole database. For instance, I am designing a database that in a report it shows the number identifier of an item, and the actual detailed information is located in a separate form. What I want it to do is to be able to find the detailed information from a command within the report that only has the number identifier.

View 2 Replies View Related

Search Form - Print

Jun 21, 2007

I have been on numerous topics on this site and managed to pick up bits here and there to get my db to work as I would like with the exception of the print report button.

I can preview the result in a subform of the search that I have done, and it is this I would like to print – not sure what this should be as you can search on numerous criteria.

Edited - removed code and added file

View 2 Replies View Related

Modules & VBA :: How To Print Report Without Displaying Report

Jul 8, 2015

On this form, there is a text box for Quantity...At the end of the form, there will be a button that when pressed:The current record the data on the form is entered for is saved,A report is printed on a specific printer,I do not want the report to actual display,The number of copies it prints should be equal to what the quantity field indicates.I do have the report already created and the Quantity field is on the report (just not visible).Once this all happens, it should return the user to the form, that is blank, waiting for a new record entry.

View 1 Replies View Related

Using One Search Button To Search 4 Tables In A Database?

Mar 10, 2008

I have a database that uses four forms and each form has it's own table and each form has it's own search button to find a specific record within that table. I would like to use one search button that will look at all four tables and bring up the correct record when the request number is entered. Can I link all the tables to perform this or is code required? Can someone send me in the right direction for how to do this? Give me an example of code if it's required?
Thanks for any help I can get.

Laura Edmark

View 7 Replies View Related

Print Report To PDF

Apr 28, 2005

Hey Guys,

I have searched and searched for this on the forum but to no avail. :(

I have just installed Adobe Acrobat 6.0 and so can create PDFs. Does anyone know the code I need for a button on a form to print a report to PDF format?

Many thanks,

Rusty
:D

View 4 Replies View Related

Print Pop-up Modal Report

Jun 29, 2006

I have a report that opens from a command button on a form. The settings on the report are set to pop-up and modal to keep the focus on the report until closed. I like the settings as they are but I need to print the report once it pops up. As the settings go, I cannot access or use the toolbars to print the report. How can I print the report from the pop-up, modal view? :mad:

Thank you in advance for all your help

View 3 Replies View Related

Print Report By Macro

Aug 16, 2007

Is there a way to print a report from a form by using VBA or a macro? If so how can this be done?

View 1 Replies View Related

On Report Print, Run Query

Apr 2, 2008

I'm not sure if this is possible in Access, but I was wondering if there is a way to automatically run an Update query when a report is printed.

More specifically, I have confirmation reports, and I want the date printed and confirmation sent fields to be updated upon printing. I have an update query ready, but because I'm not going to be the person actually doing the work, I'd like the update query to be run automatically.

View 7 Replies View Related

Print Report From Listbox

Jun 4, 2005

I have a report that is dependent on the content of a single text box (a student's name). I would like to be able to select multiple names from a listbox and loop through those names to print the reports. So far, no success.

I believe that if I could pass the name of the student during the loop to the text box, the report would print properly.

Below is an attempt to pass the names in the listbox to the textbox.

Set frm = Forms![Student Reports]
Set ctl = frm![lstStudentNames]

For Each vItem In ctl.ItemsSelected

Me.txtCurrentStudentName = ctl.ItemsSelected

Next v Item

Obviously this is not correct. Any ideas?

Thanks.

View 3 Replies View Related

Print Report From Form

Oct 2, 2005

I have a form which records the progress of a complaint investigation. There are 3 reports I would like to run from this form using command buttons. They are report_long (shows all activity) report_short (summary) and logsheet.
The primary key is complt#.
How do I ensure that the complaint being printed is the complt# I have on the form?

View 6 Replies View Related

Print Report From Form

Mar 10, 2006

Please bear with my ramblings, but I’m not sure what you may find relevant.

I am currently doing work for a service company where the employees are required to wear the company’s uniform. When someone joins the company they are required to purchase their own uniform. After a year, the company buys the replacement uniform. Each year on the anniversary date, the employee is given their annual evaluation. At that time they are given a requisition to go to the uniform supplier for new uniform articles.

Each item in the uniform has a life span. For example, shirts and pants are replaced each year, winter coats and spring/fall coats are replaced every three years, caps every two years etc.

I have a form which lists the item no., description and cost of each item and when they are due to be replaced. For example
Winter coat last replaced on 2003/11/10, replacement date is calculated to 2006/11/10
When this employee has his evaluation this November, he will be entitled to a new winter coat. The calculations are done by clicking an option button beside the item on the form. Clicking replaces the issue date with Date() and adds three years to the issue date using DateAdd for a new replacement date. Clicking the button also indicates that the item is to be replaced.

NOW, I have all this working.

What I would like to do is find some way of printing the requisition from this form before closing it. Something along the lines of:

If Option1 is yes
Print this item on the requisition
Endif

And do this on every item on the form, if it’s yes, print it on the requisition, if its no ignore it.

The option buttons are not part of the underlying tables or query only part of the form.

If I’m doing this backwards, please let me know. I’m well ahead of my deadline.

View 1 Replies View Related

Form/Report Print

Mar 22, 2006

I have a form and the information on the form is displayed in a report so the user can print it out.

I have placed a command button on the form so that when you press the button you can print the report.

I was wondering if there was a way how i could just get it to print of the specific page i was on at the time.

Thanks for any help

View 1 Replies View Related

Can't Print Out What's On The Listbox To The Report

Sep 5, 2006

Hi,

I was wondering if anyone might be able to help me here. I have two tables, staff_table and salary_table.

Staff_table has the following fields,
Staff_ID, Staff_FN, Staff_LN,...

Salary_table has the following fields,
Sal_ID, Staff_ID, Sal_Date, Pay_Amt,...

In the salary form, i have a listbox that shows records of the joining of the two tables, because i'd like to be able to show the FirstName and LastName of staff. So Staff_table is joined to Salary_table via Staff_ID.

And also, in the form, i have a button to print out whatever's listed out in the listbox. It also has a combobox that is to filter the records by Staff_ID.

The salary report is created using the query named QSalary. QSalary is as a result of the joining of the two tables, Staff and Salary.

I hope i haven't lost you this far.

What doesn't work is when i filter by the Staff_ID of 10(michael), i can see there are a few number of records shown just for michael and i want to have them printed out on the report but it doesn't work. it shows the whole records in the salary table.

Here is my code

nlist = Me.LB_Salarylist.ListCount

For ncount = 0 To nlist - 1
stlinkcriteria = ",'" & Me.LB_Salarylist.ItemData(ncount) & "'" & stlinkcriteria
Next ncount

If Len(stlinkcriteria) > 0 Then
stlinkcriteria = "[QSalary.Sal_ID] In (" & Mid(stlinkcriteria, 2) & ")"
' i have tried [Sal_ID] and [Salary_table.Sal_ID], none of them work.
End If

stDocName = "Salary_SumReport" ' for producing salary summary report

DoCmd.OpenReport stDocName, acPreview

Your help is greatly appreciated.

Thank you in advance

View 2 Replies View Related

Report Cut Off In Print Preview

Aug 27, 2004

I have a report based on a form and when I view the report in print preview, part of it has been truncated. I have attached a screenshot of it. Is there a better way for me to print the form other than as a report? If not, how do I show the entire report without leaving out any part of it?

Thanks a lot

View 6 Replies View Related

Don't Print Blank Report

Sep 6, 2004

Is there a way to avoid printing a blank report if there is no data in the query?

Thanks in Advance - John

View 2 Replies View Related

Probleme With Print Report

Feb 1, 2005

this my first post in this forum.
with my bad english i try to have an answer for my problem with this code
Code: Private Sub Commande105_Click()On Error GoTo Err_Commande105_ClickDim stDocName As StringstDocName = "Invoice"DoCmd.OpenReport stDocName, acPreviewDoCmd.SelectObject acReport, "Invoice"DoCmd.PrintOut acPages, , , acNormal, 3DoCmd.Close acReport, "Invoice"DoCmd.SetWarnings FalseDoCmd.RunSQL "Update tbl1 set check1 = true where check1 = false "DoCmd.SetWarnings TrueExit_Commande105_Click:Exit SubErr_Commande105_Click:MsgBox Err.DescriptionResume Exit_Commande105_ClickEnd Sub

i use this code when there is no data to print

Code:Private Sub Report_NoData(Cancel As Integer)MsgBox "No data found! Closing report."Cancel = TrueEnd Sub

when there is no data to print and by clicking cancel this code print the form where my command
button is on!!!!!
any help please

View 1 Replies View Related

Print The Same Report Twice On One A4 Sheet

Oct 9, 2007

Hope someone can give me some pointers. I have a report for a delivery ticket this prints customers address + delivery ticket number. Below this heading it list all the items associated with that delivery number.

What I would like to have it do is print one copy of the report on the top half of an A4 sheet of paper and then Print the same copy on the bottom of the A4 sheet.

This would give me top half copy as delivery copy and bottom half copy as customers copy. The sheet would be perforated across the middle to allow the driver to tear the sheet in half and leave the customer with their copy.

Any suggestions would be appreciated

View 6 Replies View Related

Print Report Command

Feb 6, 2008

Hello there,

I was implementing a "preview report" button to one of my forms that has a subform in it. To give you background, the form shows customer information, and the subform shows all invoices outstanding for a particular customer.

When I place the "preview report" button in the subform with where all the invoices are listed, its main goal is as the name says to preview the invoice that I have already setup (in report view). It prompts me with a "enter parameter" pop-up box with the line:

"Forms!FrmSalesInvoiceViewEditFINAL!invoice_id"

I have two questions:

1) How do I change "Forms!FrmSalesInvoiceViewEditFINAL!invoice_id" for it to say some other thing?

2) How do I have the pop-up box so that instead of prompting me to enter a parameter, that instead it "takes a value" from a textbook I designate and show up with the corresponding invoice.

For example:

when I click the "preview invoice" button, the corresponding invoice pops based on taking invoice number 2007001 (instead of asking me to input 2007001 as the parameter".

Thanks in advance!

View 8 Replies View Related







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