473,625 Members | 3,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parameter box when try to preview report

56 New Member
Expand|Select|Wrap|Line Numbers
  1. Sub PreviewReport_Click()
  2. On Error GoTo Err_PreviewReport_Click
  3.  
  4.     Dim stRepName As String:    Rem Holds the Report name
  5.     Dim stDispId  As String:    Rem Holds the Dispenser ID
  6.     Dim stQuery   As String:    Rem Holds the Query name
  7.     Dim stWhere   As String:    Rem Holds the where clause
  8.     Dim stExtra   As String:
  9.     Dim stMonthYear, stYear, stWeekCount As String
  10.     Dim intX As Integer, rst As Recordset
  11.     Dim dtEndDate As Date
  12.  
  13.     stRepName = Form.cbReports
  14.  
  15.     If IsNull(Form.cbDispenser) Then
  16.        MsgBox ("Please pick a Dispenser.")
  17.        GoTo Exit_PreviewReport_Click
  18.     End If
  19.  
  20.     stDispId = Form.cbDispenser
  21.     stWhere = ""
  22.  
  23.     If IsNull(Form.cbMonthYear) Then
  24.         MsgBox ("Please pick a Month")
  25.         GoTo Exit_PreviewReport_Click
  26.     Else
  27.         stMonthYear = Form.cbMonthYear
  28.         stYear = Format(CDate("1 " & Form.cbMonthYear), "yyyy")
  29.     End If
  30.  
  31.  
  32.     dtEndDate = Nz(DMax("EndDate", "Dispensers", "[ID] = " & stDispId), cLowDate)
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. If stRepName = "Weekly Dispenser Sales" Then
  40.     stQuery = "Weekly Dispenser Sales"
  41.     stWhere = "format(START_DT,""MMMM YYYY"") = """ + stMonthYear + """"
  42. ElseIf stRepName = "Individual Weekly Sales" Then: Rem Sheet 8
  43.     If dtEndDate <> cLowDate And _
  44.         Format(dtEndDate, "YYYYMMDD") < Format(CDate(cbMonthYear), "YYYYMMDD") Then
  45.  
  46.             MsgBox ("There are no records for this Dispenser in this month")
  47.         Exit Sub
  48.  
  49.     Else
  50.         stQuery = "Individual Weekly Sales"
  51.        stWhere = "SALES.DISPENSER_ID = " + stDispId + " and format(START_DT,""MMMM YYYY"") = """ + stMonthYear + """"
  52.     End If
  53. ElseIf stRepName = "Company Weekly Sales" Then
  54.     stQuery = "Company Weekly Sales"
  55.  
  56.  
  57. ElseIf stRepName = "Company Monthly Sales" Then
  58.     stQuery = "Company Monthly Sales"
  59.  
  60. ElseIf stRepName = "Company Year End" Then
  61.     stQuery = "Company Year End"
  62.     stWhere = "SALES.WorkingWeek=-1"
  63. ElseIf stRepName = "Dispenser Comparison Monthly" Then: Rem Sheet 11
  64.     stQuery = "Dispenser Comparison Monthly"
  65.  
  66. ElseIf stRepName = "Dispenser Comparison Yearly" Then
  67.     stQuery = "Dispenser Comparison Yearly"
  68.     stWhere = "Year= " & stYear & " and SALES.WorkingWeek =-1"
  69. ElseIf stRepName = "Individual Monthly Sales" Then
  70.     If dtEndDate <> cLowDate And _
  71.         Format(dtEndDate, "YYYY") < Format(CDate(cbMonthYear), "YYYY") Then
  72.  
  73.         MsgBox ("There are no records for this Dispenser in this year")
  74.         Exit Sub
  75.     Else
  76.         stQuery = "Individual Monthly Sales"
  77.         stWhere = "DISPENSER_ID=" & stDispId
  78.     End If
  79. ElseIf stRepName = "Individual Year End" Then
  80.     stQuery = "Individual Year End"
  81.     stWhere = "DISPENSERID=" & stDispId & " and SALES.WorkingWeek = -1"
  82. End If
  83.  
  84. DoCmd.OpenReport stRepName, acPreview, stQuery, stWhere
  85.  
  86. Exit_PreviewReport_Click:
  87.     Exit Sub
  88.  
  89. Err_PreviewReport_Click:
  90.     MsgBox Err.Description
  91.     Resume Exit_PreviewReport_Click
  92.  
  93. End Sub
  94.  
hey guys the above code is for a preview report button on a main menu.

one of the options for the report is to pick a report type, the pick the dispenser, the the month

so for example INDIVDUALmonthl ey SALES , JOE BLOGS for the month of JUNE.


so i would like it to look in the weekly sales report, extract the sales for JOE BLOGS for the month of june to be displayed.

below is the query im trying to use to extract the information


Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT DISTINCTROW SALES.DISPENSER_ID, DISPENSERS.FORENAME + " " + DISPENSERS.SURNAME AS Dispenser, format(START_DT,"mmmm") AS [Month], format(START_DT,"yyyy") AS [Year], Sum(SALES.WorkingWeek)*-1 AS NoOfWeeks, count(format(START_DT,"mmmm yyyy")) AS PETE, Sum(SALES.SALES) AS TotalSales, Sum(SALES.SALES_UNITS) AS TotalSalesUnits, Sum(SALES.PHILIPS) AS TotalPhilips, iif(Sum(Sales)=0,0,Sum(DONE)/Sum(SALES)) AS SellingAppDone, iif(Sum(Sales)=0,0,Sum(BOOKED)/Sum(SALES)) AS SellingAppBooked, iiF(Sum(SALES_UNITS)=0,0,Sum(SALES_VALUE)/Sum(SALES_UNITS)) AS AvgPrice, Sum(SALES_VALUE)/Sum(SALES.WorkingWeek)*-1 AS AvgSalesPerWeek, IIF(Sum(SALES_UNITS)-Sum(SALES)=0,0,Sum(SALES)/(Sum(SALES_UNITS)-Sum(SALES))) AS BinauralSales, Sum(SALES_VALUE) AS TotalSaleValue, null AS LessCancelled, Sum(FITTED_UNITS) AS FittedUnits, Sum(FITTED_VALUE) AS FittedValue, null AS LessCancel, Sum(DONE) AS AppDone, Sum(BOOKED) AS AppBooked, Sum(DONE)/Sum(SALES.WorkingWeek)*-1 AS AvgPerWeekDone, Sum(BOOKED)/Sum(SALES.WorkingWeek)*-1 AS AvgPerWeekBooked, cDate('1 ' & format(START_DT,"mmmm") & " " & format(START_DT,"yyyy") ) AS OrdDate
  3. FROM PERIOD INNER JOIN (DISPENSERS INNER JOIN SALES ON DISPENSERS.ID = SALES.DISPENSER_ID) ON PERIOD.ID = SALES.PERIOD_ID
  4. GROUP BY SALES.DISPENSER_ID, DISPENSERS.FORENAME, DISPENSERS.SURNAME, format(START_DT,"mmmm"), format(START_DT,"yyyy")
  5. ORDER BY SALES.DISPENSER_ID, cDate('1 ' & format(START_DT,"mmmm") & " " & format(START_DT,"yyyy") ), cDate('1 ' & format(START_DT,"mmmm") & " " & format(START_DT,"yyyy") );
  6.  
  7.  
  8.  

but im getin a parmeter box which is asking for me to enter parameter value cDate('1 ' & format(START_DT ,"mmmm") & " " & format(START_DT ,"yyyy") ) ?? i have no idea why.

i get parmeter boxes when i try and preview alot of the reports........ .........its so confusing, i dont kno were to start looking
Mar 28 '07 #1
6 1837
Rabbit
12,516 Recognized Expert Moderator MVP
but im getin a parmeter box which is asking for me to enter parameter value cDate('1 ' & format(START_DT ,"mmmm") & " " & format(START_DT ,"yyyy") ) ?? i have no idea why.
That's because you're trying to sort by a field that doesn't exist. If you look at the SORT BY statement of your SQL you will see 2 calculated fields that don't exist and hence you can't sort by them.
Mar 28 '07 #2
DavidOwens
56 New Member
That's because you're trying to sort by a field that doesn't exist. If you look at the SORT BY statement of your SQL you will see 2 calculated fields that don't exist and hence you can't sort by them.

so take the ORDER BY off and it should work,
. but would that let me pick a report, chose a dispenser by say 12/05/02-17/05/02 and will display the sales for that period?
Mar 28 '07 #3
DavidOwens
56 New Member
so take the ORDER BY off and it should work,
. but would that let me pick a report, chose a dispenser by say 12/05/02-17/05/02 and will display the sales for that period?
no adivce?
Mar 29 '07 #4
Rabbit
12,516 Recognized Expert Moderator MVP
so take the ORDER BY off and it should work,
. but would that let me pick a report, chose a dispenser by say 12/05/02-17/05/02 and will display the sales for that period?
Filtering for a records within a range of dates is never done through the ORDER BY as ORDER BY only sorts the records returned. If you want to filter for a date range you do it through the WHERE clause.
Mar 29 '07 #5
DavidOwens
56 New Member
Filtering for a records within a range of dates is never done through the ORDER BY as ORDER BY only sorts the records returned. If you want to filter for a date range you do it through the WHERE clause.

ideas? please
Apr 1 '07 #6
Rabbit
12,516 Recognized Expert Moderator MVP
Well, to filter for a range of dates it would be WHERE #Date1# AND #Date2#.
Apr 1 '07 #7

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

Similar topics

3
12993
by: Aaron | last post by:
Hello, I'm trying to limit a report to a list of parameters that I pass in. The report and the underlying query both use the column FirstName. Whenever I try to limit the FirstName in via the "Where" clause, I get prompted to input the FirstName parameter, even though I'm passing it in via OpenReport The syntax I tried using:
3
10747
by: bruce | last post by:
Hello, In Access 2003 one can use OpenReport with the acDialog parameter to open a report modally. However, doing this prevents the report's toolbars from displaying. Is there a way around this? I would like to be able to open a report modally and still allow my users to print in the way they've become accustomed to, i.e., by clicking on the Print button on the toolbar. Bruce
5
2395
by: teddysnips | last post by:
I have been asked to look at an Access application. It generates a report successfully, so that you can see it on the screen with no errors. However, when you try to print it, the prompt dialog for missing parameter is displayed. Anyone any thoughts? Sorry it's rather sort on detail, but I've been passed the details of
7
4630
by: TC | last post by:
I've produced an Access application for a client. For one report, text gets cut-off at the right margin when we print the report. It does this only when we print; it doesn't happen when we view the report in preview mode. Also, it occurs only at the client site; it doesn't occur at my office or on any other computer I've tried. I can describe the problem best with a specific example. (This is a contrived example, but it is faithful to...
2
5421
by: mudman04 | last post by:
Hi, I searched online for some similar issues that I am facing but was not able come up with anything. I am fairly new with Access (2 months experience) and I am trying to remove a message stating, ENTER PARAMETER VALUE when I am generating a report. I know that the culprit lies in the query stored in the report. I have entered data in the CRITERIA (entered forms!frmproducts!lngproductID) window and OR (entered...
6
12465
by: fieldja | last post by:
I have a form called OwnerForm. It contains a combo box called Owner. The combo box looks up names from a table called OwnerName. It contains fields called OwnerID and Owner. I also have a main form called ProjectsForm. This form has several fields to enter data. I have a query that is called Owner Query. This query contains the fields IDNumber.Projects2 Team.Projects2 and Owner.OwnerName getting information from tables. On the...
1
4116
by: Ben | last post by:
NooB: Anyone help with what I could be doing incorrectly here? Trying to have a parameter drop down list where a user can select one or more of the available values contained in the table to filter out results. Have a single table with five values. Keep getting the following error.... Table name is Name Field is NickName Parameter name is "Nick", datatype string, prompt "Select NickNames",
1
5068
by: waltnixon | last post by:
I've got an MS Access query which runs fine when double clicked and returns all of the rows in a test database I'm building. I've set up a multi group report based on the query. I immediately began getting the "Enter Parameter Value" dialog and it was asking for the query by its name "sel_report_data" whenever I tried to run or preview the report. To troubleshoot the problem, I selected the query in the database window, hit the "New...
11
7320
by: Gord | last post by:
When I open a certain report, it runs some code that generates the records that will be displayed in that report. This works fine. When I go to print preview the report it appears that the code is run again? This is causing certain error problems. 1 Why does the code run for a print preview when the report already exists? 2 What command do I use in code to find out if a report (or any other object for that matter) is already...
0
8256
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8694
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8497
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7184
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4193
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.