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] & "*"
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
I want to be able to print preview a report based on 1 record record selected in the subform. So using the example above i'd like to print the record on say 01/01/13 as a report that contains all the information from the item table and only the information on the 01/01/13 from the record table.
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
I'm having difficulties with building a printing option for specific goods selected on the list.
I have a form which contains a subform. On the main form user is able to select supplier and based on the supplier can choose article that he's interested in. On the subform user gets the list of all the goods that are connected with that specific article.
I want be able now to select specific goods from subform list (using checkbox value) and based on the selection print a separate label for each goods.
I stumbled on to a Dynamic Multi Search form on this site and have been tailoring it to my organization's directory of contacts. Everything was going good until I was asked to include a search by groups to which each individual may belong. The data in the table is contained in Yes/No check boxes for around 30 different groups. I am hoping to add a combo box to the Dynamic Search as a means to pull up individuals in any 1 category. Below are two attempts at what I thought might work, however, neither performs any filtering.
Code: Private Sub Groupbox_Change() Dim db As Database Dim qdf As QueryDef Dim strSQL As String Set db = CurrentDb Set qdf = db.QueryDefs("qryGroup")
I need to print a specific form based on the selection made on a combo box.
I have been able to set it up to open the relevant form when the user selects an option from the combo box, but am unable to find a way to be able to print the specific report based on the selection.
I have a command button which prints a report based on the data in my current form, but would like it to also print the specific form based on the combo box selection.
I have the following code which i found on another thread on this forum (thanks to original author) which is attached to the On Click of a button which prints the report corresponding to the details displayed in the form.
Dim strCriterion As String Dim strMsg As String, strTitle As String Dim intStyle As Integer
This works fine, however, i need to be able to select the report based on more than 1 criteria. For example, the Reference Number can be repeated but is distinguishable from each other by an Issue Number i.e. ReferenceNumber = 93, Issue 1 or 2 etc. At present when i run the above it prints all versions of, in this case, reference number 93, which given that each report is only a single page isn't a show-stopper but it would be nice to have it working as i would like.
I have tried adding to the strCriterion line such as strCriterion = "[ReferenceNumber]=" & Me![ReferenceNumber] and "[IssueNumber]=" & Me![IssueNumber] but no joy. I have tried bracketing the whole line and variations thereof, again no joy.
Can anybody tell if what i am attempting to do is possible and if so how do i go about it?
I have tried the above coding using MasterID which is the Autonumber PK but it produces an "Enter Parameter Value" box for MasterID. Obvioulsy if i can get it to work for the Autonumber then my problem goes away but i can't seem to figure out why it works for Reference Number (Number) and not MasterId (Autonumber)?
I have to print a label quickly every time that the product hit the warehouse. The label has been created as a report linked to the query that will provide the info to the report. In order to make this report printing as quick as possible the idea is to scan the sample id from the product and once the label is printed scan the next sample and an on.
I'm not an expert on VBA but I have created the following scrip but the reports doesn't pop up.
Here is the code:
Dim SampleID As String SampleID = InputBox("Enter Sample ID") If SampleID > 0 Then DoCmd.OpenReport "rptGRM_QuickPrintLabelDymo", acViewPreview, , "[Sample]=" & SampleID Else DoCmd.Close End If End Sub
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:
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.
I am using the Navigation form and I have a tab that has all the sales quotes for a particular salesperson. Because my salespeople like to work with paper I have created sub tabs which contain a report with the same information but filtered based as follows: this Month, this year, and Last year. This report needs to be printable based on the filtered information so I created a print button within the report however when clicked it prints the entire report not the filtered report.
The filter criteria is located in the navigation button, navigation where under the data properties. I have the on click event of the button set to open the report in print preview but I need to know how I filter the where in the macro to read the criteria from the active navigation button property?
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.
I have database with an userform called AssignWP, combobox called WPDevBy, listbox called List352 (Multi select) and table called Justified.I am trying to update one field WPDevelopedBy of the table as combobox value based on list box multi selected records.
I have report that I open in reportview. On this report there is a button wich would allow the user to print the report. I have put the following code behind the button:
If MsgBox("Are you sure you want to print the report?", vbQuestion + vbYesNo) = vbYes Then DoCmd.RunCommand acCmdPrint End If
The printdialog is appearing on the screen but if I click print nothing is happening.
Is it not possible to print a report like this?
As all the ribbons are hidden I am not able to use the access print button.
I'm trying to print a Report specific to the record i'm viewing on my Form. I've created a Report linked to the Table - "SCJobsheet".I've created a button in my Form;
Name; cmdSCJobsheet Caption: Print Record OnClick: [Event Procudure]
[code]...
The Report is opening but shows Every record (Not just the one I'm viewing in the Form.
1- Open the Report called : ConsentForm 2- Print it to PDF printer (report is currently defaulted to that printer driver) 3- Save to folder: C:SOSConsentForms 4- Save as: Consent_[Last]_[First] (these are field names on the form) Result i.e.: C:SOSConsentFormsConsent_Doe_John 5- Then send the file by email (Outlook) to : abc@hotmail.com
Actually I need to select printer before printing report. That's why I need to call printer dialog to select printer using "PrintObject" in macro. But it's print the form not report. I need to print a specific report.
I have a module in my database that creates an appointment based on a table of sessions. The module works in all respects, except two:
1) When I declare optional attendees it sometimes shows them as required attendees in the actual meeting in outlook, but not always
2) The .Send method does not seem to work. It creates the appointment on my calendar as the originator of the appointment, but does not send to the other recipients.
Below is the code:
Code: Private Sub SchedOutlook() Dim rsEmployee As DAO.Recordset Set rsEmployee = CurrentDb.OpenRecordset("Select * FROM Employee INNER JOIN tblSession ON Employee.EmpID = tblSession.EmpID;", dbOpenDynaset) Dim rsMentor As DAO.Recordset
Is there a way to show the earliest and latest dates of a report generated by a non-date field?
E.g. I generate a report based on Food, and it'll list the days that this food is associated with. Is there a way to show the first and last day that appears in this report (i.e. the range of dates that the report shows based on the food selected)
I have VBA code for a Print Preview button on the main form that previews the current record in a separate Report using this code:
Code: Private Sub cmdPrintRecord_Click() Dim strWhere As String
If Me.Dirty Then 'Save any edits. Me.Dirty = False End If
[code]....
I use this Print Preview code on a Button in the Form Header. The Main form lists head of household information. I also have a tabbed control with three tabs that have SubForms for Address, Children and Contact details. The problem I have is that if any of the subforms are left blank I get a Run-Time Error '3021': No Current Record. If I Debug (press the button), it takes me straight to this line:
highlighted in Yellow.Anyone on my database must have an address, should have contact details and could have children. If any one of these is blank then the print preview will not work.I would like to know how to stop this error happening for blank records in my subforms.