473,473 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Is it possible to take input data from criteria and use it to replace name of a pdf?

86 New Member
So i have a parameter query that accepts the value of a date. when i run the query, the input box or criteria pop up appears, asks me for a date, and then the results appear..

is it possible to take whatever i typed in the criteria and use it later when i want to send an email and take that date and use that as my pdf name?

1. i open the parameter query report
2. a popup box appears and asks to me put in a date
3. i put in a formatted date say 8/2011
4. the report opens
5. it takes the 8/2011 i typed and outputs the file using the following command, appends the strReportName and adds the 8/2011 i typed somewhere in the string
strReportName is "Tickets Closed for "
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, strDestination & strReportName & ".pdf", False
6. when file has been outputted, the name should be the following: Tickets Closed for 8/2011.pdf

is that possible?

thanks!
Aug 10 '11 #1
7 1351
NeoPa
32,556 Recognized Expert Moderator MVP
No.

Parameter queries are for either :
  1. The noddiest of work, that will never require any further development.
  2. Being controlled by code so the parameters are set by the code rather than by the operator.
If you're using it for a report then you should reconsider your approach.

Typically, such filtering is done by getting the response from a control on your form, then using that to create a filter string and passing that in the OpenReport call. That way the code already has access to the value and further processing using that value is straightforward.
Aug 10 '11 #2
Jeffrey Tan
86 New Member
@NeoPa:

I'm a bit confused. Can you show me an example or some code that'll help me understand this problem?

You're saying that I need to include a control in a form and the value I type into the control will be used in the report.

So it's going to be a two step process?

Create a form with one text field and a button. when i enter the formatted date (mm/yyyy) and i click the button, the value from the textfield will be used as a filter sring for the report and then i can use that in the report name when using the output call for email.
Aug 10 '11 #3
NeoPa
32,556 Recognized Expert Moderator MVP
@Jeffrey
A two step process is still simpler than what you're working with now. Your confusion is merely related to what you're familiar with. The suggested alternative is far simpler overall (not least because it can be made to work whereas the alternative cannot).

Let me see if I can paint a picture that's easier to follow :

Start with a Form frmA, a query qryB and a report rptC.
rptC is bound to qryB. frmA has a TextBox txtA1 which will be used for filtering qryB, and by association, rptC. frmA also has a CommandButton cmdA2 which triggers running rptC. tblD contains three fields D1, D2 and D3. qryB selects its data from tblD.

rptC has three TextBox controls (txtC1, txtC2 and txtC3) bound to the qryB fields (B1, B2 and B3). txtA1 is a filter for txtC1. It can work for different types of field but for simplicity I'm going with a numeric, ID type field. All Clear so far I hope. For now I will ignore error handling, to allow the basic logic to be more clearly shown.

There are two basic methods for handling this and I will illustrate them here :
  1. My preferred method is to grab the data from txtA1 into the code and build a filter string. qryB, in this scenario, would be :
    Expand|Select|Wrap|Line Numbers
    1. SELECT [D1] AS [B1]
    2.      , [D2] AS [B2]
    3.      , [D3] AS [B3]
    4. FROM   [tblD]
    The code behind cmdA2, for building the filter string and opening the report, would be like :
    Expand|Select|Wrap|Line Numbers
    1. Private Sub cmdA2_Click()
    2.     Dim strWhere As String
    3.  
    4.     strWhere = "[B1] = " & Me.txtA1
    5.     Call DoCmd.OpenReport(ReportName:="rptC", WhereCondition:=strWhere)
    6. End Sub
  2. The alternative puts the filter into the query itself. I don't like this approach as it relies on the form being open (which it's designed to be, but when it isn't it's a nuisance). The SQL for qryB in this case would be :
    Expand|Select|Wrap|Line Numbers
    1. SELECT [D1] AS [B1]
    2.      , [D2] AS [B2]
    3.      , [D3] AS [B3]
    4. FROM   [tblD]
    5. WHERE  [D1] = Forms!frmA.txtA1
    The code for cmdA2 in this scenario would be commensurately simpler of course :
    Expand|Select|Wrap|Line Numbers
    1. Private Sub cmdA2_Click()
    2.     Call DoCmd.OpenReport(ReportName:="rptC")
    3. End Sub
Aug 11 '11 #4
Jeffrey Tan
86 New Member
can you briefly explain to me the filter on the report

the filter is the "WHERE" clause in the query?

I added this in the report form open

Expand|Select|Wrap|Line Numbers
  1. Dim result As String
  2.  
  3. result = InputBox("Enter Month and Year", "Tickets Opened", "m/yyyy")
  4.  
  5. Me.Filter = "Format([user_problem_log.date_closed],'m/yyyy')='" & result & "'"
  6.  
Aug 12 '11 #5
NeoPa
32,556 Recognized Expert Moderator MVP
This post doesn't seem to engage very much with the topic so far. It's as if you've jumped off the rails and rejoined the track somewhere up ahead (with little clue as to where you are now).

Let's assume you are going with the filter approach outlined in #1 from post #4. Let's also assume (because that's the closest idea I can come to of what you're talking about) that you want the code in the report to be aware of the value (txtA1) used to filter the report.

In that case (and let me know if I'm off-track myself here) then you should be aware that there are two approaches to this availabe :
  1. The simplest would be to pass an OpenArgs parameter from the calling code, as well as the WhereCondition parameter. This needs no further explanation.
  2. The alternative would be to get this information out of the Me.Filter string in you Form_Open() procedure :
    Expand|Select|Wrap|Line Numbers
    1. Private strDate As String
    2.  
    3. Private Sub Form_Open()
    4.     strDate = Split(Me.Filter, "'")(1)
    5. End Sub
Aug 12 '11 #6
Jeffrey Tan
86 New Member
@NeoPa:

I think I may have completely confused you with my goal to this problem.

Let me go back to square one.

I have a form "List of Reports" that contain the following fields
1. combobox - includes all my reports
2. command button open - opens the report
3. email button - emails the report, however, some have parameters.

There are two reports specifically that require the user to enter a parameter value and that is a date field that I've formatted to accept the month and year (m/yyyy).
Then the report opens and filters the records based on the month and year I entered.

Now when I want to email this, it works no problem. It's just that the "Subject" and the "Report Name" for the docmd output that I'm having a problem with.

I would like to set it so that somewhere in the Subject and Report Name is the m/yyyy I entered so that when the recipient opens up the email, he/she can easily see what month and year the report is.
Aug 12 '11 #7
NeoPa
32,556 Recognized Expert Moderator MVP
Right. That explains where you're coming from, but not why you you still seem to have code using the InputBox() function and what it is you still don't understand from my answers so far (It seems to me they answer all of your questions).

I'm sure I can help further, but I need to know where you're confused. What don't you understand from the answers already given?
Aug 12 '11 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: wildchild | last post by:
Hi, I am new to grpahics progamming in/under Borland C. I have included the "graphics.h" header file but i am unable to take input on the screen. if i try to move my cursor to a specified...
1
by: Grey | last post by:
I have created a asp.net form for user to input data. After input the data, user need to click a button to export the input data to excel for data analysis with excel pivot table function. is it...
2
by: Magnus | last post by:
I'm currently developing an application with classified information as input to a couple of algorithms. Which strategy should I use to protect the input data from beeing read? The files should...
17
by: stathis gotsis | last post by:
Hello everyone, I am tying to come up with an elegant way to process some input data that come from a form. When the user hits the 'Submit' button, i want the form to appear again with the...
1
by: JJ | last post by:
Is it possible to count the number of columns that match certain conditions and return a single value? For example in the database we have a record where: Column 1 = Male Column 2 = A Column...
5
markmcgookin
by: markmcgookin | last post by:
Hi Folks, I am designing an app in VB 2003 (as a lot of you prob already know!) I have some code the queries an SQL Server CE Database and comapares the data retrieved to a letter the user...
4
by: jane007 | last post by:
Hello everybody: I am having a problem. On Unix platform, there is a script that need user to input data from console, then when I call Unix perl script from Windows, these is an issue occurs,...
2
by: eko99312 | last post by:
Dear All, As you know that input data on excel is easy than access, you can simple click the date that you prefer and input the value that you want. For example : Consider that the month that I...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.